Hello
We are writing to ask about the project not found error on our short-lived branch analysis. We using sonarcloud for a group project at the university and come across a problem for our short-lived branch. Our setup is as follows:
- CI and Git host → gitlab selfhosted by the university
- Sonarcloud setup → Because gitlab is selfhosted, we had to follow the setup for non-integrated build environment
- Language → Java 17
- Build Tool → Maven
- Sonar Maven Plugin Version → 3.9.1.2184
- Gitlab CI:
image: maven:3.9.0-amazoncorretto-17
stages:
- code_style_check
- unit_test
- code_quality_analysis
variables:
MAVEN_CLI_OPTS: >-
-Dsonar.login=$SONAR_TOKEN
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=xx
-Dsonar.projectKey=xx_xx
-Dsonar.branch.name=Pipeline_Fix
-Dsonar.branch.target=main -Dsonar.verbose=true -X
code_style_check:
stage: code_style_check
script:
- mvn checkstyle:check
unit_test:
stage: unit_test
script:
- mvn test
code_quality_analysis:
stage: code_quality_analysis
script:
- 'mvn verify sonar:sonar $MAVEN_CLI_OPTS'
Our gitflow consist of a main branch and shortlived feature branches.
The main branch analysis always works without any problems, but the shortlived branch always crashes when the analysis should be uploaded. We tested the branch analysis also locally and it worked, but on the CI it crashes.
For testing purpose we hardcoded the branch.name (pipeline runs on the correct branch). The organization and projectKey are redacted also the stuff in the log message.
Here are the detailled error message:
[INFO] 15:38:45.700 Analysis report generated in /builds/x/target/sonar/scanner-report
[DEBUG] 15:38:45.700 Upload report
[DEBUG] 15:38:45.783 POST 404 https://sonarcloud.io/api/ce/submit?organization=xx&projectKey=xx_xx&projectName=xxx&characteristic=branch%3DPipeline_Fix&characteristic=branchType%3DSHORT | time=83ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.707 s
[INFO] Finished at: 2023-04-07T15:38:45Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project x: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project x: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
We would like to know where the error lies.
Thank you for your help in advance.