我正在计算詹金斯管道动态阶段内的局部变量(S_STACK_ID)的值 我需要将S_STACK_ID变量传递给makefile,以便可以在makefile中使用它来唯一标识要部署的ECS堆栈
我尝试了下面的代码,但是它将空白的“ ARGS”传递给makefile
stage('build') {
steps {
script {
def stages = [failFast:true]
for (int i=1; i<5; i++) {
stages["LG ${i}"]={
stage ("LG ${i}"){
S_STACK_ID=env.STACK_ID+i
withCredentials([[
sh 'make ARGS="${S_STACK_ID}" build'
}
}
}
}
parallel stages
}
}
}
sh 'make ARGS="myStack" build' //This correclty passes "myStack" to makefile
sh 'make ARGS="${S_STACK_ID}" build' // Passess blank to makefile and not the value of S_STACK_ID which is an issue for me
谢谢
答案 0 :(得分:0)
shell命令插入字符串文字时必须使用“ p”作为
sh“清理\” ARGS = $ {S_STACK_ID} \“”