Answers: <p>Well, you can pass multiple goals to maven in command line simply by passing them as arguments. 
  <a href="https://maven.apache.org/plugins-archives/maven-surefire-plugin-2.12.4/examples/skipping-test.html" rel="nofollow noreferrer">Skipping test require a java system property</a> that you can also pass as an argument to the command line. </p>
  
  <p>For packaging a maven artifact, executing a sonar analysis with the maven goal but skipping executing the tests you should use :</p>
  
  <p><code>mvn package sonar:sonar -DskipTests</code></p>
  
  <p>Before that, you need to decide if you want to put sonar settings in the maven configuration (i.e. <code>pom.xml</code> or <code>.m2/settings.xml</code>) or in the Jenkins server configuration.</p>
  
  <ul>
  <li><p>With maven only, the <code>sonar:sonar</code> goal needs some requirements and maven configuration that you can find <a href="https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven" rel="nofollow noreferrer">here in the documentation</a>. Jenkins use will be reduced to execute maven, you won't need to install a Jenkins plugin.</p></li>
  <li><p>Using Jenkins with sonar also needs some requirements and Jenkins configuration that you can find <a href="https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzingwiththeSonarQubeScanner" rel="nofollow noreferrer">here in the documentation</a>. Be sure to install the Sonarqube scanner Jenkins plugin. This plugin enable some Jenkins integration features.</p></li>
  </ul>
  
Answers: CC BY-SA 3.0
Answers: 2017-04-28T20:49:15.287Z
Answers: 2017-04-28T20:58:33.467Z
Answers: 2017-04-28T20:58:33.467Z
Answers: Fanch
Body: <p>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. </p>
  
  <p>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 (<code>sonar:sonar -Dsonar.host.url=http://url</code>)? </p>
  
  <p>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?</p>
  
Tags: <jenkins><continuous-integration><builds><build-pipeline><hudson>
Title: Maven command for Sonarqube analysis
UserDisplayName: pandey
ThreadText: # Maven command for Sonarqube analysis
  
  (Asked by: username_0 on 2017-04-27)
  
  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?
  
  **Tags:** jenkins, continuous-integration, builds, build-pipeline, hudson
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-04-28. Score: 4 | Accepted answer
  
  Well, you can pass multiple goals to maven in command line simply by passing them as arguments.
  [Skipping test require a java system property](https://maven.apache.org/plugins-archives/maven-surefire-plugin-2.12.4/examples/skipping-test.html) 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](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven). 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](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzingwiththeSonarQubeScanner). Be sure to install the Sonarqube scanner Jenkins plugin. This plugin enable some Jenkins integration features.
  
  
  ---
  
  