DevOps pipeline does not automatically create SonarCloud project

Hi,

We’ve been using SonarCloud in our organization for a few .NET projects. We have a standardized Azure DevOps pipeline which prepares and runs the SonarQube analysis during build steps in Pull Requests, and deploy pipelines that run main branch analysis once PR’s are merged to the main branch.

Yesterday when I started to run the first pipeline of a new project, the build pipeline suddenly failed when running the SonarCloudAnalyze@3 step with the following error:

ERROR: Could not find a default branch for project with key ‘Camas.Adapters.Files’. Make sure project exists.

In the past, the pipeline step would automatically create projects that did not exist yet, but this time, is does not seem to work. Once I encountered this, I tried creating the project in SonarCloud manually and rerunning the pipeline, but still the same issue occurred.

Another thing I noticed, when I went to General Settings -> Repository binding of the manually created project, I got the following:

Looks like the repository binding feature with DevOps is also broken, as that error in the bottom left keeps popping up when trying to search for repositories.

Might that be related to the issue in my pipeline?

Thanks in advance!

Hey @hugo_camas!

I think there are two seperate points here.

Can you check that the user who is running analysis explicitly as the Create Projects permission at the org level?

The team tells me this got fixed late last night. Can you try again?

Hey Colin! Thanks a lot for your reply.

I didn’t have the permissions to create projects. Does that mean that the DevOps pipeline runs it’s requests on behalf of the DevOps user that initiated the pipeline? I’m not able to test this currently, as we managed to get it working by manually creating a project and making sure the project key matched the project key specified in the pipeline. I will keep in mind to test this on later projects to see if the permission has fixed the issue!

Yes, it works again! Thanks :slight_smile:

Not quite. It runs as the user for whom you generated the SonarQube Cloud token (that is provided here). This user must have the permissions to create projects.