Skip to content

Instantly share code, notes, and snippets.

@mkutz
Last active March 22, 2019 08:02
Show Gist options
  • Save mkutz/bbe944aca42f7b73fffc1d5fd3f6c813 to your computer and use it in GitHub Desktop.
Save mkutz/bbe944aca42f7b73fffc1d5fd3f6c813 to your computer and use it in GitHub Desktop.
This Jenkinsfile describes a pipeline to build and (optinally) release a Maven library.
#!/usr/bin/env groovy
// see https://jenkins.io/doc/book/pipeline/syntax/
pipeline {
agent any
tools {
maven "Maven"
}
triggers {
pollSCM "* * * * *"
}
options {
timestamps()
ansiColor("xterm")
}
parameters {
booleanParam(name: "RELEASE",
description: "Build a release from current commit.",
defaultValue: false)
}
stages {
stage("Build & Deploy SNAPSHOT") {
steps {
sh "mvn -B deploy"
}
}
stage("Release") {
when {
expression { params.RELEASE }
}
steps {
sh "mvn -B release:prepare"
sh "mvn -B release:perform"
}
}
}
post {
always {
deleteDir()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment