- We are using Sonarqube Developer Edition - 8.5.1
- Our goal is to achieve “automatic PR decoration”
- We have configured the integration between Sonarqube and Bitbucket Server (v7.4.2) following the instructions at https://docs.sonarqube.org/latest/analysis/jenkins/
- Configured the Sonar Scanner - We use gradle for our builds - followed: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-jenkins/
- Then followed the instructions for PR decoration: https://docs.sonarqube.org/latest/analysis/pull-request/
The PR decoration works, if we pass the following parameters in the gradle.build file:
property ‘sonar.pullrequest.key’, ‘68’
property ‘sonar.pullrequest.base’, ‘master’
property ‘sonar.pullrequest.branch’, ‘feature/sonarqube_properties’
However, its desirable to pass these parameters programatically by Jenkins, as we often do not know the ‘sonar.pullrequest.key’ until after the Pull Request is raised.
As per https://docs.sonarqube.org/latest/analysis/pull-request/ , in the analyses parameters section at the end of the document, the statement “Scanners running on Jenkins with the Branch Source plugin configured, GitLab CI/CD, and Cirrus CI automatically detect these parameters, and you don’t need to pass them manually”
– We use Jenkins as our CI/CD tool…but it appears that Jenkins is either not passing these values (Bitbucket Branch Source plugin is configured correctly) or the pipeline step withSonarQubeEnv(‘SonarQube’) is ignoring these values. I cant find a document that details what env variables can be passed automatically and how to enable them.
Note: Our Sonarqube scanner runs on a docker container. Is there a way to pass these values through the Jenkins when it pulls and builds the docker container? Or is there any other way?
Any help would be appreciated.