【发布时间】:2018-02-13 06:54:59
【问题描述】:
在 Jenkins 中,我想获取用户输入并传递给 shell 脚本以供进一步使用。
我尝试设置为环境变量,但是shell脚本无法获取最新值,旧值是echo。
pipeline {
agent none
environment{
myVar='something_default'
}
stages {
stage('First stage') {
agent none
steps{
echo "update myVar by user input"
script {
test = input message: 'Hello',
ok: 'Proceed?',
parameters: [
string(name: 'input', defaultValue: 'update it!', description: '')
]
myVar = "${test['input']}"
}
echo "${myVar}" // value is updated
}
}
stage('stage 2') {
agent any
steps{
echo "${myVar}" // try to see can myVar pass between stage and it output expected value
sh("./someShell.sh") // the script just contain a echo e.g. echo "myVar is ${myVar}"
// it echo the old value. i.e.something_default
}
}
}
}
【问题讨论】:
标签: shell jenkins jenkins-pipeline