Analysis of the project isn't shown on Main Branch Evolution graph

On my project, the PR analyses are successfully sent and we can see the result per PR but somehow those analyses aren’t reflected in Main Branch Evolution graph since July 2020.

How can we analyze the main branch of the project constantly?

Hey there.

Welcome to our Community!

How is your project being analyzed today? Do you use Automatic Analysis, or CI-based analysis (if CI-based analysis, which CI do you use?)

Hello Colin,

Thank you for replying me.

We are using CI-based analysis. More precisely, we are executing this command on Buildkite

$ sonar-scanner -Dsonar.login='token' -Dsonar.pullrequest.base='base-branch' -Dsonar.pullrequest.branch='target-branch' -Dsonar.pullrequest.key='key' -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=our-project

Hey there.

If your repository is hosted on GitHub (and that’s where your pull requests are being raised) there should actually be no need to supply any of these analysis parameters.

After removing these (and testing that your pull request analyses still work as expected), you simply need to make sure that the sonar-scanner command (or whatever step you’ve added to your build that accomplishes this) is also running on builds of your main branch, not just on pull requests.

Thank you for the suggestion.

I tried to remove those options, then I was able to confirm the dev branch analysis started again, however, it seems to stop sending PR analysis instead.
Is there any efficient way to make both of the analyses compatible?

Thanks for the update.

Is your project bound? By this I mean, did you provision it from the project onboarding UI and do you see an icon like this on your project homepage?

Yes I am seeing the GitHub logo there and it takes me to the repo on GitHub :frowning:

Hey @kazu9su

Thanks for the additional information.

So I was wrong – you are required to set sonar.pullrequest.* parameters because we don’t automatically detect any branch/pull request analysis parameters for GitHub. There might be some baby steps we could take to make this happen (which I’ll ping about internally), but for now, you need to do the following:

In your build, you’ll need to switch between two scanner commands whether your just building a branch, or whether you’re building a pull request.

When building branches, you’ll need to include set to the branch being built Buildkite sure has the environment variables you need!)

When building pull requests, you’ll need to set sonar.pullrequest.* as you were before.

Thanks, Colin

Writing if condition by the building target worked!

  /opt/sonar-scanner/bin/sonar-scanner -Dsonar.login=$SONARCLOUD_TOKEN -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.key=$BUILDKITE_PULL_REQUEST
  /opt/sonar-scanner/bin/sonar-scanner -Dsonar.login=$SONARCLOUD_TOKEN -Dsonar.pullrequest.provider=GitHub$BUILDKITE_BRANCH

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.