Skip to content

Instantly share code, notes, and snippets.

@iskandarsaleh
Created November 27, 2018 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iskandarsaleh/7dc94f0d031d5ec170fd97f0e3292130 to your computer and use it in GitHub Desktop.
Save iskandarsaleh/7dc94f0d031d5ec170fd97f0e3292130 to your computer and use it in GitHub Desktop.
node {
def mvnHome
stage('Preparation') { // for display purposes
// Get some code from a GitHub repository
git 'https://github.com/jglick/simple-maven-project-with-tests.git'
// Get the Maven tool.
// ** NOTE: This 'M3' Maven tool must be configured
// ** in the global configuration.
mvnHome = tool 'maven-1'
}
stage('Build') {
// Run the maven build
if (isUnix()) {
sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore clean package"
} else {
bat(/"${mvnHome}\bin\mvn" -Dmaven.test.failure.ignore clean package/)
}
}
stage('SonarQube analysis') {
// requires SonarQube Scanner 2.8+
def scannerHome = tool name: 'maven-1', type: 'maven';
withSonarQubeEnv('sonar-6')
{
sh "${mvnHome}/bin/mvn sonar:sonar"
}
}
stage('Results') {
junit '**/target/surefire-reports/TEST-*.xml'
archive 'target/*.jar'
}
}
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.5.0.1254</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment