0

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

Community
  • 1
  • 1
nehrka
  • 1
  • 1

1 Answers1

1

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

  • Thanks for your answer. After messing around with different JDKs the maven goal variant works fine, except the fact that I don't know where to put properties like `sonar.scm.disabled=true`. I tried to set it in sonar.properties and in sonar-scanner.properties and it doesn't work in neither of them. As stated in my initial question I would like to put this in a central place. Any suggestions? – nehrka May 19 '17 at 07:03
  • If you are using Maven, a good way to share a property with all your projets is to put it in the parent pom of your organization (even if I don't recommend disabling SCM feature). – Julien H. - SonarSource Team May 30 '17 at 06:59