Skip to content

Instantly share code, notes, and snippets.

@abayer
Forked from rsandell/examplePipeline.groovy
Last active April 1, 2021 08:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save abayer/9964eb7ff7a1a6b86a054e968c26c772 to your computer and use it in GitHub Desktop.
Save abayer/9964eb7ff7a1a6b86a054e968c26c772 to your computer and use it in GitHub Desktop.
Example declarative pipeline
pipeline {
agent none
environment {
MAVEN_OPTS = "-Xmx1024m"
}
parameters {
stringParam(defaultValue: "install", description: "What Maven goal to call", name: "MAVEN_GOAL")
}
jobProperties {
buildDiscarder(logRotator(numToKeepStr:'1'))
}
triggers {
cron('@daily')
}
stages {
stage("Build") {
agent docker: "maven:3.3.9-jdk-8"
steps {
checkout scm
sh "mvn clean ${env.MAVEN_GOAL} -B -Dmaven.test.failure.ignore=true"
}
post {
success {
archive "**/target/**/*.jar"
junit '**/target/surefire-reports/*.xml'
}
}
}
}
postBuild {
always {
echo "Build done"
}
}
notifications {
success {
mail to: "abayer@cloudbees.com", subject: "Build Successful"
}
failure {
mail to: "abayer@cloudbees.com", subject: "Build Failed"
}
unstable {
mail to: "abayer@cloudbees.com", subject: "Build Unstable"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment