Declarative pipeline syntax - variable scope?

def let_it 

pipeline {
  agent none

  stages {

    stage('Checkout') {
      steps {
        script {
          let_it = 'snow'
        }
      }
    } // .stage.checkout

    stage('Build') {
      steps {
        println "Weather is: " + let_it
        script {
          println " ... and in script: " + let_it
        }
      }
    } // .stage.build

  } // .stages
} // .pipeline

1 Like