Skip to content

Instantly share code, notes, and snippets.

@macg33zr
Created November 28, 2016 10:43
Show Gist options
  • Save macg33zr/a687304194fbc6eab81434bf1a21fafe to your computer and use it in GitHub Desktop.
Save macg33zr/a687304194fbc6eab81434bf1a21fafe to your computer and use it in GitHub Desktop.
Jenkins pipeline model definition - how to disable with an environment variable
// Check for early exit of a pipeline. The env check has to be inside a node.
boolean earlyExit = false
node {
echo "env.PIPE_DISABLED = ${env.PIPE_DISABLED}"
if(env?.PIPE_DISABLED == 'true') {
earlyExit = true
}
}
if(earlyExit) {
echo "Early exit pipeline as disabled"
return
}
pipeline {
// Run on any node
agent label: ""
stages {
stage('foo) {
steps {
echo "Foo stage executed"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment