Alexis
(Alexis.L)
December 8, 2020, 9:08am
1
Hello ,
I’m trying to use sonarqube (developper edition in evaluation) tu use merge request decoration with gitlab.
I cannot have any results.
i use
sonarqube 8.5.1.38104
sonar-scanner 4.3.0.2102 (Java 11.0.3 AdoptOpenJDK (64-bit) - Linux 4.19.62-mod-std-ipv6-64-rescue amd64)
Gitlab CE 13.6.1
I configure sonar as describe in https://docs.sonarqube.org/latest/analysis/pr-decoration/
in /admin/settings?category=almintegration
I define my GitLab URL : https://gitlab.mycompagny.com/api/v4/
I set my personal key with api scope permission
Merge Request Decoration & Import repositories from your ALM are displayed as enabled.
i set my gitlab project id in my sonar project sonfiguration
I use sonar-scanner using with cli in a gitlab-ci job .that is trigger on each commits.
Can you help me to use merge request decoration?
Hi, is the merge request analyzed on SonarQube? Can you access it? When you are browsing the MR page, Is there any warning displayed at the top-right of the page?
Alexis
(Alexis.L)
December 8, 2020, 10:31am
3
Thanks Pierre (are you french?)
There is nothing in sonar MR page
I maybe need to define sonar.pullrequest.xx variable. ? I will try this
Alexis
Can you please share with us your .gitlab-ci.yml
file?
Alexis
(Alexis.L)
December 8, 2020, 11:04am
5
I just add sonar.pullrequest.* variables.
Now i can see merge request in sonarqube but there is no decoration un gitlab.
Here my .gitlab-ci.yml
variables:
SONAR_PROJECT: "test"
SONAR_SOURCES: "./"
stages:
- Quality
Quality:Sonar:MergeRequests:
stage: Quality
script:
- /opt/sonar-scanner/bin/sonar-scanner -Dsonar.projectKey=$SONAR_PROJECT -Dsonar.qualitygate.wait=true -Dsonar.sources=$SONAR_SOURCES -Dsonar.pullrequest.key=$CI_MERGE_REQUEST_ID -Dsonar.pullrequest.base=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME -Dsonar.pullrequest.branch=$CI_MERGE_REQUEST_LABELS
only:
- merge_requests
You don’t need those, the scanner detects them, according to our documentation for Gitlab CI/CD pipeline.
The most important piece is
only:
- merge_requests
That trigger merge pipeline, that will contain the env variable that can be detected. Now that you have your MR analyzed, any warning on the MR on SQ?
Alexis
(Alexis.L)
December 8, 2020, 12:20pm
7
Ok, i deleted -Dsonar.xxx it work without this indeed
I got a warning on sonar :
Could not find ref ‘master’ in refs/heads, refs/remotes/upstream or refs/remotes/origin. You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis.
Alexis
(Alexis.L)
December 8, 2020, 12:32pm
8
I juste retry a new merge request and now it seems to be OK !
I cannot understant what happend but it seems to be good now
This error happens when you stay on the default clone strategy, a shallow clone. This is why we advise using
GIT_DEPTH: "0"
as env variable, to ensure the scanner will find others branches in the local git repo after the clone.
system
(system)
Closed
December 15, 2020, 12:41pm
11
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.