Maven command for Sonarqube analysis

7,130

Well, you can pass multiple goals to maven in command line simply by passing them as arguments. Skipping test require a java system property that you can also pass as an argument to the command line.

For packaging a maven artifact, executing a sonar analysis with the maven goal but skipping executing the tests you should use :

mvn package sonar:sonar -DskipTests

Before that, you need to decide if you want to put sonar settings in the maven configuration (i.e. pom.xml or .m2/settings.xml) or in the Jenkins server configuration.

  • With maven only, the sonar:sonar goal needs some requirements and maven configuration that you can find here in the documentation. Jenkins use will be reduced to execute maven, you won't need to install a Jenkins plugin.

  • Using Jenkins with sonar also needs some requirements and Jenkins configuration that you can find here in the documentation. Be sure to install the Sonarqube scanner Jenkins plugin. This plugin enable some Jenkins integration features.

Share:
7,130

Related videos on Youtube

pandey
Author by

pandey

Updated on September 18, 2022

Comments

  • pandey
    pandey over 1 year

    I am planning to build a Maven project in Jenkins. I tried to do some research how to give goals for Maven for doing few steps in one command but cant get understood how to do.

    What I mean is how can I give a goal where Maven can build Maven project like creating artifact, skip tests and analyse Sonarqube analysis with particular URL like (sonar:sonar -Dsonar.host.url=http://url)?

    I tried but I am unable to give all goals at same time. I am planning to give in these three steps in three different goals. Any way that I can give in single step?