79159651

Date: 2024-11-05 15:08:57
Score: 0.5
Natty:
Report link

Adding another example and full implementation based on the answer above by @hctahkram !

upstream-job

pipeline {
  agent any
  stages {
    stage("Trigger downstream job") {
      steps {
        script {
          buildResult = build(job: "downstream-job", wait: true)
          env.A = buildResult.buildVariables.A
        }
        sh("echo $A")
      }
    }
  }
}

downstream-job

pipeline {
  agent any
  stages {
    stage("Define A") {
      steps {
        script {
          env.A = "aaa"
        }
        sh("echo $A")
      }
    }
  }
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @hctahkram
  • Low reputation (0.5):
Posted by: maze