I am trying to run my java maven project for sonar analysis. We have multiple projects with their own pom.xml and a central server settings.xml to run all those maven builds. Is there a way to configure just the settings.xml to pick sonar scanner during build and help run sonar analysis depending on the properties passed during run time. We don't want to introduce that plugin in each of the pom.xml for this. Just trying to look for an easy way to run our sonar analysis by just configuring the settings.xml.
1
votes
1 Answers
1
votes
Now it's a bit more clear.
You can do it by following the instructions in the link you posted. That first step (Initial Setup) configures the properties, but won't tell maven when to run it, as there's no plugin configuration to bind the plugin to a phase.
On the following section of that page (Analyzing a Maven Project), it says that to actually run the analysis, you have to manually run execute it. And gives 3 options:
mvn clean verify sonar:sonar
# In some situation you may want to run sonar:sonar goal as a dedicated step.
# Be sure to use install as first step for multi-module projects
mvn clean install
mvn sonar:sonar
# Specify the version of sonar-maven-plugin instead of using the latest.
#See also 'How to Fix Version of Maven Plugin' below.
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar
There are many other options, the above is just the most common approach.
So you'll need to amend you Jenkins jobs to run the analysis, either by adding the extra settings and mvn goals; or by using the Jenkins Maven Plugin, but you'll still need to configure the Jenkins plugin and add an extra step in all of your builds.
mvn org.sonarsource.scanner.maven:3.6.0.1398:sonar-maven-plugin -D...... - khmarbaise