0
votes

I just use the SonarQube-Plugin for Jenkins and configured the Jenkins job to execute the SonarQube Scanner. If I'm leaving the analysis properties in the UI and the sonar-scanner.properties blank the mandatory properties are missing. According to this question at least the sonar.projectKey should be automatically derived from the maven properties <groupId>:<artifactId>. If I set the sonar.projectKey and the sonar.sources properties directly everything works fine. But how can I achieve that the the maven properties <groupId>:<artifactId> are used by the plugin?

Edit: If I set the Analysis properties in the UI to: sonar.projectKey=${POM_GROUPID}:${POM_ARTIFACTID} and sonar.sources=. as described here it works fine. But it has no real advantage because I have to insert the same information to every job. It would be better if I can set these properties in a central file like the sonar-scanner.properties because all project dependent information is set by maven properties.

My configuration of the Post-Build-Step

1
do you use the last jenkins sonarqube plugin ? your screenshot seems oldMaxence Lecointe
I'm using the SonarQube Scanner for Jenkins in Version 2.61, my Jenkins has version 2.46.nehrka

1 Answers

1
votes

For a Maven project, you should better use the scanner for Maven. Enable "Prepare SonarQube environment" feature and simply use a standard Maven step to run mvn sonar:sonar.

Documentation: https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzingwithSonarQubeScannerforMaven