Skip to content

Instantly share code, notes, and snippets.

@harikrishna456
Forked from lvthillo/jenkins-pipeline.groovy
Created December 3, 2019 03:47
Show Gist options
  • Save harikrishna456/f39d083a52317f71d60bb19f2035087c to your computer and use it in GitHub Desktop.
Save harikrishna456/f39d083a52317f71d60bb19f2035087c 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