Project not found in sonarcloud analysis in azure devops pipelines

  • ALM: Azure Devops

  • CI: Azure Devops

  • Scanner integraded with msbuild (netcore apps) (pipeline tasks attached)

  • dotnet core

  • problem

    We use Azure Devops as our source repository.
    Azure devops is organized in team projects.
    Due to recently organization changes, we recently created new Team Projects in Azure Devops and some of the repositories are being migrated from old team projects to new ones.
    We use the repositoryname as SonarCloud Project Key, So if the repo is migrated with the same name, it should use the same key in SonarCloud.

    Sometimes, after the migration we observe the following error when running SonarCloud Analysis in azure devops pipelines after the team project migration:

2023-01-05T17:06:27.9594774Z ##[error]ERROR: Error during SonarScanner execution
2023-01-05T17:06:27.9596572Z ERROR: Error during SonarScanner execution
2023-01-05T17:06:27.9600161Z ##[error]ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
ERROR:
2023-01-05T17:06:27.9602624Z ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
2023-01-05T17:06:27.9603617Z ERROR: 
2023-01-05T17:06:28.3235446Z ##[error]The SonarScanner did not complete successfully
2023-01-05T17:06:28.3237981Z The SonarScanner did not complete successfully
2023-01-05T17:06:28.3241882Z ##[error]14:06:28.323  Post-processing failed. Exit code: 1
2023-01-05T17:06:28.3242977Z 14:06:28.323  Post-processing failed. Exit code: 1

The project exists in SonarCloud,
The Azure Devops connection used to connect to SonarCloud is shared among all the projects, so it uses the same user and password.
The user has create and execute analysis permission in SonarCloud

  • steps to reproduce:

    1. Create a repo in Azure Devops Team Project 1, run the sonarcloud analysis using reponame as key
    2. Migrate the repo to Azure Devops Team Project 2, run the sonarcloud analysis using reponame as key.
  • Known workaround:
    Remove or rename the sonarcloud project and rerun the pipeline.

Hey there.

Thanks for reaching out!

It’s not clear to me where in your pipeline the analysis is failing (the range of logs shared isn’t wide enough). Can you share additional logs from the pipeline that so exactly where the error is being raised (what’s happening in the analysis when the error is raised).

Hi. The problem happens in the SonarCloud Run Analysis step:

I uploaded the following files:

Hey there.

No doubt that your project exists based on the logs:

2023-01-05T17:05:44.5633982Z INFO: Check ALM binding of project 'chatbot-integration-gestaofrotas-vendas-api-netcore'
2023-01-05T17:05:46.1126112Z INFO: Detected project binding: NOT_BOUND
2023-01-05T17:05:46.1129298Z INFO: Check ALM binding of project 'chatbot-integration-gestaofrotas-vendas-api-netcore' (done) | time=1555ms

But this stood out:

2023-01-05T17:06:08.1412989Z INFO: Organization key: aab440a34d90e639a6858a99eb4f0656f8e14fc5

Usually organization keys are a bit more human-readable.

Are you sure the project chatbot-integration-gestaofrotas-vendas-api-netcore exists in the organization aab440a34d90e639a6858a99eb4f0656f8e14fc5 on SonarCloud (and not perhaps some different organization?)

We have just one organization and the project is private inside our organization.
This is the key displayed in our platform:
sonarcloud-key

I’ve dug into the logs a bit and have some information to share involving specific usernames. I’ll send you a private message.

A post was split to a new topic: 403 message on analysis cache