4

I am compiling a Maven project with Azure Devops Pipelines. Following is the relevant code (don't mind indentation, it's in an if branch).

I had successfully run earlier analyses on the main branch, so now I tried to fix some mistakes and open a pull request

    variables:
      # SonarCloud parameters
      sonarCloudOrganization: acmeco
      sonarCloudProjectKey: ACMECorporation_artifact-id
      sonarCloudProjectName: artifact-id


    steps:

      - task: SonarCloudPrepare@1
        inputs:
          SonarCloud: SonarCloud
          organization: $(sonarCloudOrganization)
          scannerMode: Other
          extraProperties: |
            # Additional properties that will be passed to the scanner,
            # Put one key=value per line, example:
            # sonar.exclusions=**/*.bin
            sonar.projectKey=$(sonarCloudProjectKey)
            sonar.projectName=$(sonarCloudProjectName)

          - task: Maven@3
            displayName: Build Maven Artifact
            inputs:
              mavenPomFile: pom.xml
              mavenOptions: -Xmx3072m $(MAVEN_OPTS)
              options: --batch-mode
              javaHomeOption: JDKVersion
              jdkVersionOption: 1.11
              jdkArchitectureOption: x64
              goals: clean package -DskipTests
              sonarQubeRunAnalysis: true
              sqMavenPluginVersionChoice: latest

      - task: SonarCloudPublish@1
        inputs:
          pollingTimeoutSec: 300

I have redacted the project key. The pipeline does not succeed. The error is

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project artifact-id: Project not found. Please check the ‘sonar.projectKey’ and ‘sonar.organization’ properties, the ‘SONAR_TOKEN’ environment variable, or contact the project administrator -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I have triple-checked that the pipeline's yaml file contains the correct projectKey enlisted in SonarCloud in the variable on the top.

However, Sonar Maven plugin insists on using the artifact-id name despite a SonarCloud project with key containing the organization name already exists

Example project key: ACMECorporation_artifact-id Example artifact id: artifact-id

Additional info

==============================================================================
Task         : Maven
Description  : Build, test, and deploy with Apache Maven
Version      : 3.202.0
Author       : Microsoft Corporation
Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/maven
==============================================================================

==============================================================================
Task         : Prepare Analysis Configuration
Description  : Prepare SonarCloud analysis configuration
Version      : 1.26.1
Author       : sonarsource
Help         : Version: 1.26.1. [More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-for-azure-devops/)
==============================================================================

Additional info

Today we implemented a permission model to segregate visibility of projects across different teams. Basically, a project shouldn't be visibile to new users until they are member of a group. I am administrator of SonarCloud and I originally inputed the Sonar token into Service Connection

Additional info

Today we also cleaned up some messy duplicate projects created by SonarCloud. artifact-id project, with no scans, could have been there, created from void. However, the project's correct key is ACMECorporation_artifact-id, I checked for its presence and you do understand that I am redacting the real organization and project names

Question: what does the error mean? Is it something wrong in my pipeline configuration?

usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305

0 Answers0