Skip to content

Instantly share code, notes, and snippets.

@darinpope
Last active June 21, 2022 19:24
Show Gist options
  • Save darinpope/0edce302c1ddabf8db9cf2f47f7f5541 to your computer and use it in GitHub Desktop.
Save darinpope/0edce302c1ddabf8db9cf2f47f7f5541 to your computer and use it in GitHub Desktop.

Gist for https://youtu.be/EXseAqYxZtw

Documentation

Example 1

pipeline {
  agent none
  stages {
    stage('Hello') {
      agent any
      when {
        equals expected: 2, actual: 3
      }
      steps {
        echo 'Hello World'
      }
    }
  }
}

Example 2

pipeline {
  agent none
  stages {
    stage('Hello') {
      agent any
      when {
        expression {
           sleep 10
           return true
        }
      }
      steps {
        echo 'Hello World'
      }
    }
  }
}

Example 3

pipeline {
  agent none
  stages {
    stage('Hello') {
      agent any
      when {
        beforeAgent true  
        expression {
           sleep 10
           return true
        }
      }
      steps {
        echo 'Hello World'
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment