Jenkins:可能在不使用中间文件的情况下从脚本块设置环境值。
工作看起来像:
pipeline {
agent any
environment {
file_path = "old/path"
}
stages {
stage("stage1") {
steps {
echo "Hello there!"
sh '''
NEW_PATH="/some/new/path"
'''
//How to assign NEW_PATH to file_path so below
//print stmt provides output "/some/new/path"
println file_path
}
}
}
}
我尝试了
file_path = sh(returnStdout: true, script: "echo ${NEW_PATH}").trim()
它没有帮助。