Azure DevOps / Getting main component does not belong to specified organization

  • ALM used : Azure DevOps
  • CI system used: Azure DevOps
  • Scanner command used when applicable (private details masked)
  • Languages of the repository JAVA
  • Only if the SonarCloud project is public, the URL - Not Public.
  • Error observed
    main component does not belong to specified organization
  • Steps to reproduce
    Added OOB tasks
    Prepare Analysis On SonarCloud Before gradlew Build
    and after that added
    Publish Quality Gate Result
    On gradlew build task I checked Run SonarQube or SonarCloud Analysis
    SonnarQube Scanner field: 2.7.1 also tried with 2.6.1 and 2.8

Hi, I am trying to use SonarCloud on an Azure DevOps Build Pipeline per the instructions found here

and I am getting the specified error.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ā€˜:sonarqubeā€™.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:166)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:163)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:156)
    ā€¦
    main component does not belong to specified organization

My account is a paid SonarCloud account.

I appreciate all the help.

Hi,

Could you please make sure that both organization and projectKey you have set are good ones ?

Most likely this error occur when the one or another is wrong and does not belong to the organization set.

Mickaƫl

Hello Michael
First of all, thanks for your answer.

Organization is automatically populated when you configure the SonarCloud Service Endpoint in Azure Devops.
Project Key is NOT an option when you select ā€œIntegrate with Maven or Gradleā€ on the Prepare Analysis on SonarCloud task:

Yes, in gradle/maven mode, the project key is deduced from gradle/maven properties, and this is the main reason why this message could appear : from some reason, if you havenā€™t created your project yet on SonarCloud, the project key might already exist. You can override this by setting sonar.projectKey in the Additional properties field, under ā€œAdvancedā€ tab of the configuration.

1 Like

Mickaƫl, that did the trick, maybe that should be included in the docs?
Many thanks

Good to hear !

We have something in the pipe to let the user the possibility to override directly in the config (not hidden in advanced properties) the key of the project for Gradle/Maven, but no ETA yet.