简体   繁体   中英

Derive mandatory SonarQube properties from pom file in Jenkins with SonarQube Jenkins Plung

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM