Azure DevOps Multiple Git Repo Checkout not reporting correct branch

Sonarqube Version: 8.4.1
Description: Noticed behavior where sonarqube is not reporting to results to the correct branch when Azure DevOps YAML pipeline checks out multiple repositories.
Reproduction Steps:

  1. Create basic Azure DevOps YAML Pipeline with 2 checkout steps.
  • checkout: self (Develop Branch)

  • checkout: git://Products/DevOps@refs/heads/master

  1. Run Pipeline for Develop Branch
  2. Will notice that all results are uploaded to Master branch for provided project key instead of scanned branch Develop

Has anyone experienced the same outcome as above and how were you able to resolve to have sonarqube only upload to desired branch?

Attempted workaround:

Tried to provide manually as part of the configuration. This fixed the issue, however you cannot use when scanning a Pull Request…

Hello @Jon_Kasperan,

I confirm that the behaviour that you describe is the expected one.
SonarQube always extract the branch name (or the PR details) of the last checked out branch, and I confirm that the workaround to manually override the property will not work for a pull request (because there are other information that is collected that would not correspond to the checked out branch anyway)

In your case, why do you need to check-out master after checking out develop ?


Hello @OlivierK,

The use case here is that as part of our YAML builds/releases we have a number of general use Powershell scripts that purposed for all of our build/release pipelines. As part of the build we are checking out the development branch of the application in question & the master branch of the Devops repository where the Powershell scripts are located. We use the master branch of the Devops repository because there may be development work on the Powershell scripts that we do not want the YAML pipelines to use.

It would be ideal where we could checkout multiple repositories while building for merge/pull requests where the primary branch is not the highest branch out of either repo.

Hello @Jon_Kasperan,

Ok I understand. I however believe (and that’s just my opinion, probably widely shared at SonarSource) that this is a questionable pattern. You should build the branch with all the powershell scripts as they are on that branch. If there are some changes in these script that may have an impact, they should be developed on another branch and merged when ready.
So I don’t think there’s any improvement we’d be ready to do to cover your pattern.
I hope that you understand the position.