Not able to link scm with the integration branch on sonarqube

I am trying to link scm with every project present on our sonarqube. When i try to execute below command to attach scm link with the created project on the sonar

/usr/local/Cellar/sonar-scanner/4.6.2.2472_1/bin/sonar-scanner -Dsonar.sources=././vendor -Dsonar.login=adfafdsafasweq3e -Dsonar.host.url=https://abc.xyz.net -Dsonar.links.scm=https://git.com/abc/sonarqube-example-python.git -Dsonar.projectName=xyz:xyz -Dsonar.projectKey=Sonarqube:Python:integration -Dsonar.branch.name=integration -Dsonar.sourceEncoding=UTF-8 -Dsonar.c.file.suffixes=- -Dsonar.cpp.file.suffixes=- -Dsonar.objc.file.suffixes=-

scm link does not get attached to the project, but when i change the branch to ‘master’ the scm link get attached to the project on sonar.
/usr/local/Cellar/sonar-scanner/4.6.2.2472_1/bin/sonar-scanner -Dsonar.sources=././vendor -Dsonar.login=adfafdsafasweq3e -Dsonar.host.url=https://abc.xyz.net -Dsonar.links.scm=https://git.com/abc/sonarqube-example-python.git -Dsonar.projectName=xyz:xyz -Dsonar.projectKey=Sonarqube:Python:integration -Dsonar.branch.name=master -Dsonar.sourceEncoding=UTF-8 -Dsonar.c.file.suffixes=- -Dsonar.cpp.file.suffixes=- -Dsonar.objc.file.suffixes=-

Is there any way to attach scm link with sonarqube project for integration branch?

Hey there.

Can you share some screenshots to illustrate what you expect to see (and what you see when you don’t see what you expect to see?)

Hi Colin,
When i execute the below command which has the branch.name as master it will add the scm link for the project created in the sonarqube

/usr/local/Cellar/sonar-scanner/4.6.2.2472_1/bin/sonar-scanner -Dsonar.sources=././vendor -Dsonar.login=asfasdfasf -Dsonar.host.u
rl=https://abac.asdfasdfa.net -Dsonar.links.scm=https://github.com/sonarqube-example-python.git -Dsonar.projectName=xyz:xyz:abac:abac -Dsonar.projectKey=btqw::sonarqube:Python:master -Dsonar.branch.name=master -Dsonar.sourceEncoding=UTF-8 -Dsonar.c.file.suffixes=- -Dsonar.cpp.file.suffixes=- -Dsonar.objc.file.suffixes=-

but when i execute the same command with branch as integration it does not add any scm link on the created sonarqube project

/usr/local/Cellar/sonar-scanner/4.6.2.2472_1/bin/sonar-scanner -Dsonar.sources=././vendor -Dsonar.login=asfasdfasf -Dsonar.host.u
rl=https://abac.asdfasdfa.net -Dsonar.links.scm=https://github.com/sonarqube-example-python.git -Dsonar.projectName=xyz:xyz:abac:abac -Dsonar.projectKey=btqw::sonarqube:Python:master -Dsonar.branch.name=integration -Dsonar.sourceEncoding=UTF-8 -Dsonar.c.file.suffixes=- -Dsonar.cpp.file.suffixes=- -Dsonar.objc.file.suffixes=-

The scm link is added if branch name is master. Is there any way we can add the scm link for the branches other than master?

Thanks. Project links should be scoped at the project-level (main branch is the word of truth).

  • What version of SonarQube are you using?
  • When you switch back to the master branch from integration (in the UI, not doing any additional scan) do you see the project links?

We are using sonarqube version 8.9.6.

If I scan only integration branch and then switch to master branch it displays below on the UI.

The scm link with the master will be null as well.

If we scan the master branch first and then scan integration branch then integration branch will display the scm link we provided when we scanned master branch.

@Colin Do we have any way to add scm with any other branch then master/main?

Hey there.

Everything seems to be working as expected as SCM links are tied to your main branch. Until SCM links have been provided via an analysis of your Main Branch, they will not appear.

If integration is your main branch, you can rename your main branch before the first analysis by going to Project Settings > Branches.

1 Like

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