Ajinkya
(Ajinkya)
October 2, 2024, 2:23pm
1
Hi I have GitLab repo with Gradle Java 17 configured with Sonar Cloud
ALM used (GitLab)
CI system used (GitLab)
Languages of the repository: Gradle Java 17
I am trying to analyze the Merge request, but facing issues with the Gitlab Pipeline
The pipeline fails and the merge request is not visible in Sonar cloud.
Can you please help me with this issue?
BR,
Ajinkya
Ajinkya
(Ajinkya)
October 9, 2024, 1:39pm
3
Hi @Colin
The pipeline fails with the error: Task ’ -Dsonar.organization=ads*****’ not found in root project ‘demo-sonar-test’ and its subprojects.
Colin
(Colin)
October 10, 2024, 8:36am
4
What Gradle command are you running? I’d suggest sharing your full GitLab CI YML file.
Ajinkya
(Ajinkya)
October 10, 2024, 9:20am
5
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
sonarcloud-check:
tags:
- cibuild
image: gradle:jdk17
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- gradle sonar -Dsonar.token=$SONAR_TOKEN \
-Dsonar.organization=ads***** \
-Dsonar.projectKey=ads*****_demo-sonar-test \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.verbose=true --info > log.txt
artifacts:
paths:
- log.txt
expire_in: 1 week
only:
- merge_requests
- master
- develop
Colin
(Colin)
October 10, 2024, 12:08pm
6
I think you just need quotes around your strings.
> gradle sonar -Dsonar.token=$SONAR_TOKEN \
> -Dsonar.organization="ads*****" \
> -Dsonar.projectKey="ads*****_demo-sonar-test" \
> -Dsonar.host.url=$SONAR_HOST_URL \
> -Dsonar.verbose=true --info
Ajinkya
(Ajinkya)
October 10, 2024, 12:15pm
7
I tried with quotes but still getting the same error
Task ’ -Dsonar.organization=ads*****’ not found in root project ‘ads*****_demo-sonar-test’
Ajinkya
(Ajinkya)
October 11, 2024, 5:00pm
8
Hi @Colin ,
I have attached debug logs for your reference
log.txt (2.4 MB)
Colin
(Colin)
October 14, 2024, 8:51am
9
Hey there.
I think the issue is coming down to your multiline approach. I suggest, as a debugging step, removing the line breaks.
script:
- gradle sonar -Dsonar.token=$SONAR_TOKEN -Dsonar.organization=ads***** -Dsonar.projectKey=ads*****_demo-sonar-test -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.verbose=true --info > log.txt
Ajinkya
(Ajinkya)
October 14, 2024, 11:23am
10
Hi @Colin ,
I tried without the line breaks still it fails I have attached the logs for your reference
BR,
Ajinkya
log 2.txt (3.4 MB)
Colin
(Colin)
October 16, 2024, 6:29am
11
The logs appear to show that the sonar
task is running, but eventually, you hit a 403.
2024-10-14T10:17:28.700+0000 [DEBUG] [org.sonarqube.gradle.SonarTask] ← 403 https://sonarcloud.io/api/alm_integration/show_pullrequest?project=ads*****_demo-sonar-test&pullrequestKey=1 (292ms, unknown-length body)
Is your project bound , and is the GitLab token up to date in your global Administration > Organization settings ?
Ajinkya
(Ajinkya)
October 16, 2024, 8:20am
12
Hi @Colin ,
The project is bound, I have attached a screenshot for your reference
We created a user called cicd-bot@ads*****.com in Gitlab and created personal token for him with api scope and it is set in SonarCloud
one of my colleague can see the token as valid while for me it is showing invalid
I am not sure how is this possible
Please let me know how to proceed with this
P.S We followed this post
Best Regards,
Ajinkya
Ajinkya
(Ajinkya)
October 16, 2024, 9:57am
13
Hi @Colin ,
We were able to resolve the issue.
We made cicd-bot@ads*****.com the owner of organization in Gitlab and that resolved the issue.
Thanks for all the help and support
Best Regards,
Ajinkya
1 Like
system
(system)
Closed
October 23, 2024, 9:57am
14
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.