你好,试图从Powershell脚本中的stage更新jenkins环境变量
pipeline {
agent { label 'master' }
environment {
def var1 = "default_value"
def var2 = "default var 2"
}
stages {
stage ('step-1') {
steps {
script {
powershell (returnStdout: true, script: '''
${env:var1} = "changed from powershell"
${env:var2} = "var2 changed from powershell"
''').trim()
}
}
}
stage ("step-2"){
steps {
echo var1
echo var2
}
}
}
}
我可以访问值但无法更改它们,作用域仅限于PowerShell吗?
powershell(returnStdout: true,...
的结尾括号)
。 - Trisped