Template for a good new topic, formatted with Markdown:
ALM used (GitHub, Bitbucket Cloud, Azure DevOps): AZDO;
CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI): AZDO pipelines;
Scanner command used when applicable (private details masked): sonarcloud@prepare
Languages of the repository: Java (Maven);
Only if the SonarCloud project is public, the URL
And if you need help with pull request decoration, then the URL to the PR too
Error observed (wrap logs/code around with triple quotes ``` for proper formatting): when running a pipeline for the first time, when scanning a branch that is not the Master, a new project is created using an ID as a name;
Steps to reproduce: run a AZDO pipeline with the sonarcloud@prepare stage in it; After this part a project with a ID name is created; if the branch is anyouther than the Master, it keeps the ID as project name.
Potential workaround: only run scans on Master branch.
Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!
I would like to clarify: when running this initial scan, are you passing the sonar.projectName parameter? Or are you leaving it blank? This might be configured on a per branch basis in your pipeline configuration.
Another idea to investigate: go to SonarCloud > your project > Administration > Background tasks > click on the 3 dots to the right of the 1st analysis > Show SonarScanner Context > look for sonar.projectName.
In fact, you could reproduce both cases: the case where you initially scan master and the case where you initially scan a different branch, and see the scanner context for each of them. This way you can check whether the sonar.projectName param is being sent or not in each of the cases.
This is another hint that supports the suspicion I told you in my other message: the property is being set differently depending on the branch, and it’s probably being set by your pipeline script on a per-branch basis. You should review your pipeline scripts to see where this is happening.
In fact the examples are from different projects, but in various cases here I’m running the scan without having the projects created on SonarQube, and I’m passing the project-key variable directly in the scan (with the desired project name):
when I run the scan from the main branch, the project is created accordinly;
when I run the scan in any other branch, the project is created with a strange ID as a name;
Okay, I think I see what’s going on. As per our documentation, when passing sonar.projectName via CLI, it’s only used if the analysis is running on the main branch. Otherwise, sonar.projectKey will be used as name. So in the example where you are having this issue:
I guess your project name ends up being 215b1482-c4f3-f793-955a-0a94a2003010, right? Is this something you are setting manually? It might also be getting picked up from maven props in pom.xml, such as artifactId.