我已经在我的脚本中声明了一个变量TENTATIVE_VERSION,我需要使用来自执行脚本(或来自其他阶段的脚本本身)的值来定义/修改它,我该怎么做?我当前的脚本是这样的:
pipeline {
agent {
label 'machine1'
}
stages {
stage('Non-Parallel Stage') {
agent{label "machine2"}
steps {
script {
TENTATIVE_VERSION="1.0" // working
// TENTATIVE_VERSION="sh echo 123" //not working
}
}
}
stage('Parallel Stage') {
parallel {
stage('A') {
agent {label 'machine3'}
steps {
echo "On other machine"
echo "${TENTATIVE_VERSION}"
build job: 'otherJob', parameters: [[$class: 'StringParameterValue', name: 'VERSION', value: "${TENTATIVE_VERSION}"],
[$class: 'StringParameterValue', name: 'RELEASE', value: '1']]
}
}
stage('B') {
agent {label "machine4"}
steps {
script {
STATUS_S = "OK"
}
echo "On a machine"
}
}
stage('C') {
agent {label "machine5"}
steps {
script {
STATUS_R = "OK"
}
echo "On a machine"
}
}
}
}
}