I have a situation where the build number of one job has to be passed to another job and the next job will use that as a parameter.
stages { stage('Build Job1') { steps { script { build job: "001_job" $build_001= env.BUILD_NUMBER of 001_job echo env.BUILD_NUMBER //this echos the build number of this job and not 001_job } } } stage('job_002') { steps { script { build job: "job_002", parameters: [string(name: "${PAYLOAD_PARAM}", value: "$build_001")] } } } } }