Branches not working, pull request analysis not working

We checked out our develop branch, and ran the recommend maven command:

mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ourproj_our-service

This created an initial scan, but the only branch it shows is:

master - Main branch.

(Which seems wrong, we haven’t even pushed from our develop to our master branch yet and we dont have a branch called main)

Next we created a new feature branch from develop: feature/1_new-feature, pushed it, created a pull request.

We then ran the same scanner command on this feature/1_new-feature branch.

Now in the UI, under “pull requests” there are none, under branches is still only master/main

BUT!!!

under latest activity in the overview page, it shows:

New Analysis | Main Branch Failed
10 March at 14:2 9ccd7174Merged in feature/3-csv_and_ping (pull request #8)

so it has recognized the PR branch, but this is wrong:

  1. its says main branch, but the branch was from develop.
  2. the pull request is missing in the UI
  3. the develop branch and feature branch are missing from the UI.
  4. it says +1 lines of code, but there were hundreds of lines of code changed.

Maybe its because sonar has the wrong branch as the main branch. We never want it to consider PRs against master, we would want it against develop.

Hi,

This is addressed in your other thread:

Once again, PR analysis is designed to be run from a CI, where the CI integration will automatically pick up relevant values from the environment and pass them forward to analysis. From what I can tell, you’re still doing this painfully manually. So you’ll need to provide the requisite parameters manually as well.

 
Ann

Now we are getging somewhere. The parameters you list are:

sonar.pullrequest.base=master
sonar.pullrequest.branch=feature/my-new-feature
sonar.pullrequest.key=5

the base and key have not been mentioned in other posts on this topic.

NOTE: there is no mention of these parameters in the “tutorial” “Analyze from your CI” which you seem to be saying would provide a solution.

See this one below we tired, which has the same issue that pull requests don’t work, an doesn’t include these critical parameters. It even says at the bottom that PRs will be analyzed, but we tried it - they are not.