When I run this without having created the project in SonarQube it will create the project.
This is OK but it will create the project with default parameters for new code definition and QualityGate etc. The “DevOps Platform Integration” setting will also not be configured so the quality gate reporting back to azure DevOps is not possible.
Questions:
Is it possible to configure default parameters for the creation in the pipeline ?
Is there a way to execute API calls to the SonarQube server from the pipeline that use the access token provided in the service connection ?
Prevent the project from being created automatically ? I already have a powershell script that can setup the project
Ok, but this would not include “DevOps Platform Integration” settings for “Configuration name”, " Project name" and “Repository name” because that configuration is special for each project.
So this solution does not work.
When I create a service connection in DevOps. I will enter a authentication token.
This token has access to create projects. But how can I access that token in a Powershell script inside a yaml pipeline.
How do I get $SonarQubeAccessToken
I would like to get the token from the service connection but can I do that ?
The problem with that is that other developers are allow to create new DevOps repos that will then create new SonarQube projects with the name they select. So I do not know what names they will use.
Maybe I can change the access token to only allow “Execute Analysis”, I guess then it would not allow creating projects?
You’re looking to set “default parameters for the creation in the pipeline” for project-specific values such as key and name? That’s … only available (for legacy reasons) for Maven projects.
Ah. Well, that’s really more an ADO question. I suspect the answer is “you can’t”. You would need to re-provide that token to the script.
I suppose you’re talking about a ‘Global analysis’ token here? If so you’re not going to be able to control its permissions granularly.
I suppose you could manage this by using a user token from a technical account that has analyze globally, but not create.
Was hoping for a DevOps task like (SonarQubeSetup@7) that would allow custom commands to the SonarQube server.
But OK if I go that this solution I will need to maintain the token in two locations.