Branch Analysis is not working correctly

  • which versions are you using: developer edition.
  • what are you trying to achieve: I want to run sonarqube analysis on branches and get correct results.
  • what have you tried so far to achieve this: I have configured the azure devops pipeline to run the analysis, however the issues I have is that developers will take out a branch, work on their local system and then push the code changes to bitbucket. Now branch analysis works fine when running the pipeline, but since it will use the first push as baseline, it means the code written locally on the first push is never included in the analysis, which make the feature quite useless. I think it should use the master branch as original comparison instead? or maybe I have configured something wrong?


Welcome to the community!

What you’re running into is what we mean by branch. We expect a ‘branch’ to be a longer-lived thing than for just the implementation of a single feature. I.E. a release branch. If you switched to PR analysis (and decoration) you would get the behavior you wanted.


I am using PR with decorators and it is working fine for that purpose.

However, there are situations where we might want to work on branches, and it does not make any sense that whatever is in the first push of that branch are omitted from the analysis.


For your temporary branches, you can change the default New Code definition of your project to use a reference branch. The New Code will then take into account all the changes you’ve made to the branch since it was created.

Hope it helps.

1 Like