| #!groovy |
| // Jenkins Settings |
| // Only keep the 20 most recent builds. |
| properties([ |
| [$class: 'jenkins.model.BuildDiscarderProperty', |
| strategy: [$class: 'LogRotator', numToKeepStr: '20', artifactNumToKeepStr: '20'] |
| ] |
| ]) |
| |
| // Start Build |
| timestamps { |
| // Claim a Linux build slave to work in |
| node() { |
| currentBuild.result = 'SUCCESS' |
| try { |
| currentBuild.displayName=env.BRANCH_NAME + ' #' + env.BUILD_NUMBER |
| |
| // Gain access to installed tools in Jenkins |
| def JAVA_TOOL=tool 'jdk1.8.0-latest' |
| def MAVEN_TOOL=tool 'apache-maven-latest' |
| def MEM_ARGS="-Xms512m -Xmx4096m -XX:MaxPermSize=2048m" |
| |
| stage('Preparation') { |
| timeout(time: 15, unit: 'MINUTES') { |
| checkout scm |
| } |
| } |
| |
| // Now we can run the Maven build |
| stage('Build') { |
| |
| // Setup the Environment with Java and Maven on the classpath |
| withEnv(["JAVA_HOME=${JAVA_TOOL}", "PATH+MAVEN=${MAVEN_TOOL}/bin:${env.JAVA_HOME}/bin", |
| "JAVA_OPTS=${MEM_ARGS}", "MAVEN_OPTS=${MEM_ARGS}"]) { |
| timeout(time: 90, unit: 'MINUTES') { |
| try { |
| echo "Building branch: ${env.BRANCH_NAME}" |
| wrap([$class:'Xvnc', useXauthority: true]) { |
| sh "mvn -T 8 -B -fae clean verify -DskipRCP" |
| } |
| } finally { |
| step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml']) |
| } |
| } |
| } |
| } |
| |
| // Archive the created update site so that we can use it in the future - but only |
| // for our release branches and master branch. |
| if (env.BRANCH_NAME.equals("master")) { |
| timeout(time: 15, unit: 'MINUTES') { |
| stage('Archive Artifacts') { |
| // Fingerprints will allow this artifact to be traceable if a downstream job |
| // references it in the future. |
| archiveArtifacts artifacts: 'releng/org.eclipse.tigerstripe.update-site/target/*.zip', fingerprint: true |
| } |
| } |
| } |
| } catch (any) { |
| currentBuild.result = 'FAILURE' |
| throw any |
| } finally { |
| if (currentBuild.result != 'ABORTED') { |
| step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'danijoh2@cisco.com', sendToIndividuals: true]) |
| } |
| } |
| } |
| } |