Skip to content

Instantly share code, notes, and snippets.

@mkutz
Last active August 3, 2020 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkutz/5a5dedcc736497bbde4819e7a4a5c7d8 to your computer and use it in GitHub Desktop.
Save mkutz/5a5dedcc736497bbde4819e7a4a5c7d8 to your computer and use it in GitHub Desktop.
Jenkinsfile using script and if for an optional step
#!/usr/bin/env groovy
// see https://jenkins.io/doc/book/pipeline/syntax/
pipeline {
agent any
parameters {
booleanParam(name: "RELEASE", defaultValue: false)
}
stages {
stage("Build") {
steps {
sh "./gradlew build"
}
}
stage("Publish") {
steps {
script {
if (params.RELEASE) {
sh "./gradlew release"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment