Skip to content

Instantly share code, notes, and snippets.

@lvthillo
Last active December 3, 2019 03:47
Show Gist options
  • Save lvthillo/9a8b5bd84947bacc606760c86990ec04 to your computer and use it in GitHub Desktop.
Save lvthillo/9a8b5bd84947bacc606760c86990ec04 to your computer and use it in GitHub Desktop.
Example Jenkins Maven pipeline which uses slackNotifier.groovy
/* import shared library */
@Library('jenkins-shared-library')_
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '3'))
}
parameters {
booleanParam(name: 'SKIP_TESTS', defaultValue: false, description: 'Check if you want to skip tests')
}
tools {
maven 'maven 3.5.3'
}
stages {
stage('Checkout Git repository') {
steps {
git branch: 'master', credentialsId: 'git-credentials' , url: 'https://github.com/lvthillo/maven-hello-world'
}
}
stage('Maven Build') {
steps {
sh 'mvn clean install -DskipTests=$SKIP_TESTS'
}
}
}
post {
always {
/* Use slackNotifier.groovy from shared library and provide current build result as parameter */
slackNotifier(currentBuild.currentResult)
cleanWs()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment