This is an automated email from the ASF dual-hosted git repository. martin_s pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/archiva-parent.git
commit 64a37b55b51b1f33b3f327b592b763bd309e9828 Author: Martin Stockhammer <[email protected]> AuthorDate: Thu May 17 22:13:22 2018 +0200 Switching to declarative jenkins pipeline --- Jenkinsfile | 120 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 62 insertions(+), 58 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 451adfa..78a608f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,78 +1,82 @@ -def labels = 'ubuntu' -def buildJdk = 'JDK 1.8 (latest)' -def buildMvn = 'Maven 3.5.2' -def deploySettings = 'DefaultMavenSettingsProvider.1331204114925' +LABEL = 'ubuntu' +buildJdk = 'JDK 1.8 (latest)' +buildMvn = 'Maven 3.5.2' +deploySettings = 'DefaultMavenSettingsProvider.1331204114925' -node(labels) { - try { - stage('Checkout') { - checkout scm - } - } catch (Exception e) { - notifyBuild("Checkout Failure") - throw e +pipeline { + agent { + label "${LABEL}" } + stages { - try { - stage('Build') { - timeout(20) { - withMaven(maven: buildMvn, jdk: buildJdk, - mavenSettingsConfig: deploySettings, - mavenLocalRepo: ".repository" - ) - { - // Run test phase / ignore test failures - sh "mvn -B -U -e -fae clean install" - } - // Report failures in the jenkins UI - //step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml']) - } - if (isUnstable()) { - //notifyBuild("Unstable / Test Errors") + stage('Checkout') { + steps { + checkout scm + } + post { + failure { + notifyBuild("Checkout failure (${currentBuild.currentResult})") + } + } } - } - } catch (Exception e) { - notifyBuild("Test Failure") - throw e - } - try { - stage('Publish') { - timeout(10) { - withMaven(maven: buildMvn, jdk: buildJdk, - mavenSettingsConfig: deploySettings, - mavenLocalRepo: ".repository" - ) - { - sh "mvn -B -U -e -fae deploy" - } - // Report failures in the jenkins UI - //step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml']) + + stage('BuildAndDeploy') { + steps { + timeout(20) { + withMaven(maven: buildMvn, jdk: buildJdk, + mavenSettingsConfig: deploySettings, + mavenLocalRepo: ".repository", + options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true), + findbugsPublisher(disabled: true), artifactsPublisher(disabled: true), + invokerPublisher(disabled: true), jgivenPublisher(disabled: true), + junitPublisher(disabled: true, ignoreAttachments: false), + openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)] + ) + { + // Run test phase / ignore test failures + sh "mvn -B -U -e -fae clean deploy" + } + // Report failures in the jenkins UI + //step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml']) + } + } + post { + success { + archiveArtifacts '**/target/*.pom' + } + failure { + notifyBuild("Failure in BuildAndDeploy stage") + } + } } - if (isUnstable()) { - //notifyBuild("Unstable / Test Errors") + } + post { + unstable { + notifyBuild("Unstable Build") + } + always { + cleanWs deleteDirs: true, notFailBuild: true, patterns: [[pattern: '.repository', type: 'EXCLUDE']] + } + success { + script { + def previousResult = currentBuild.previousBuild?.result + if (previousResult && !currentBuild.resultIsWorseOrEqualTo(previousResult)) { + notifyBuild("Fixed") + } } } - } catch (Exception e) { - notifyBuild("Publish Failure") - throw e } } -// Test if the Jenkins Pipeline or Step has marked the -// current build as unstable -def isUnstable() { - return currentBuild.result == "UNSTABLE" -} - // Send a notification about the build status def notifyBuild(String buildStatus) { // default the value buildStatus = buildStatus ?: "UNKNOWN" def email = "[email protected]" - def summary = "${env.JOB_NAME}#${env.BUILD_NUMBER} - ${buildStatus}" + def summary = "${env.JOB_NAME}#${env.BUILD_NUMBER} - ${buildStatus} - ${currentBuild?.currentResult}" def detail = """<h4>Job: <a href='${env.JOB_URL}'>${env.JOB_NAME}</a> [#${env.BUILD_NUMBER}]</h4> <p><b>${buildStatus}</b></p> <table> @@ -90,4 +94,4 @@ def notifyBuild(String buildStatus) { ) } -// vim: et:ts=2:sw=2:ft=groovy +// vim: et:ts=4:sw=4:ft=groovy -- To stop receiving notification emails like this one, please contact [email protected].
