Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save szydan/32ce4ae2a6cd26403e75aa8f1475f54c to your computer and use it in GitHub Desktop.
Save szydan/32ce4ae2a6cd26403e75aa8f1475f54c to your computer and use it in GitHub Desktop.

Gist for https://youtu.be/41uUsWQjKRw

Scripted pipeline example

def animal="cat"
node {
  stage('hello') {
    echo animal
    animal = "dog"
  }
  stage('goodbye') {
    echo animal
  }
}

Declarative pipeline example

def animal="cat"
pipeline {
  agent any
  stages {
    stage("hello") {
      steps {
        script {
          echo animal
          animal = "dog";
        }
      }
    }
    stage("goodbye") {
      steps {
        script {
          echo animal
        }
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment