which versions are you using:
SonarQube Developer Edition v10.5.1
how is SonarQube deployed: zip, Docker, Helm
Not sure, almost certainly on a self-hosted VM inside the corporate network.
what are you trying to achieve
Run scans consistently.
We use a SonarQubePrepare@7 task inside our Azure DevOps build pipeline yml file to run scans against our Python code on a SQ server. The DevOps project has a service connection which uses a Global type PAT token created in my user account on the SQ server. My user has Execute Analysis permission on the SQ project associated with the scan. The sonar-users group to which I belong also has global execute analysis permission.
This has been set up like this for months and 99.9% of the scans run as expected. But intermittently, when I create a new branch in my Python project, all scans by SQ appear to fail on that branch with:
16:24:34.653 ERROR You're not authorized to analyze this project or the project doesn't exist on SonarQube and you're not authorized to create it. Please contact an administrator.
The only way round this Iāve found is to create a new branch with the same code changes. This is pretty frustrating, and happens to one of my colleagues occasionally too. I did see this but Iām not sure itās related.
Thanks @ganncamp. Iāve tried loads of different things today - created new branches in different ways, deleted and recreated the service connection from Azure DevOps to SonarQube, using both global and user type tokens from SQ. Iām now an admin on this server and have given myself āexecute analysisā permission as a user. But every single run I do now fails - unless I trigger a run on the master branch! If I ask someone else to trigger a run on my branch, that too fails with the same error: You're not authorized to analyze this project...
Okay, first 10.5.1 is a bit long-in-the-tooth at this point. Can you upgrade to the current version, 2025.1 LTA, and see if this is replicable? To be honest, Iām not aware of anything specific w/r/t this thatās been addressed since 10.5.1, but this is an obligatory first ask.
Also is the pipeline exactly the same for main and branches, or are there two different sets of commands? Iām focused on this part of the error when I ask that:
Youāve got global analyze. Do you have global create?
Also, can you provide a full, debug analysis log starting from the analysis command itself?
Yes, we also have access to a much more recent SonarQube Enterprise server. The long-term plan is to switch to using that instead but some networking issues between that and DevOps would need to be resolved first.
The pipeline does not (AFAIK) treat different branches differently w.r.t. SonarQube. This was all working fine (except occasionally failing intermittently) until yesterday.
Yes I do have global create permission. This is what I see for me under Global Permissions > Users:
Iām running a new build on my branch now with system diagnostics enabled from DevOps. If you mean some other kind of debugging then pls let me know how to enable that.
For that, you really need to talk to your network folks. I can only guess that the query string for a branch contains some phrase thatās ātriggeringā the proxy.
@ganncamp - thank you so much! By trial and error I found that somethingās changed recently (in the firewall protecting SonarQube?) that means that any branch names that include a hyphen (ā-ā) will trigger the 403 error and hence:
ERROR You're not authorized to analyze this project or the project doesn't exist on SonarQube and you're not authorized to create it. Please contact an administrator.
If I replace all the hyphens in the original branch name with underscores then the build passes fine. Iāll follow up with the SQ admin as there may have been some recent firewall changes (as hyphens in branch names was working as recently as 10 Feb.)ā¦
Just a suggestion for SonarSource, assuming this hasnāt already been done in a later release of SonarQubeā¦
Perhaps the error message displayed in response to a 403 (You're not authorized...) can be reworded to include the possibility of a network or firewall error; as I wasted many hours yesterday needlessly fiddling with my user permissions, PAT tokens and DevOps service connections. The existing error message led me down a blind alley.