bash - 如何将管道阶段变量传递给makefile
问题描述
我正在计算 jenkins 管道动态阶段内的局部变量 (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
谢谢
解决方案
这是因为 shell 命令需要 "" 来插入字符串文字
sh "清理\"ARGS=${S_STACK_ID}\""
推荐阅读
- jmeter - 我的 jmx 文件中有很多 HTTP 请求,我只想一次点击一个 HTTP 请求,而不管所有线程都没有设置
- windows - 如何使用特定用户的命令行在 Windows 中查看文件夹权限?
- blueprism - 蓝棱镜中是否存在网页异常处理
- python - 使用 Gtk 和 pycairo 在图像上绘制形状
- android - 从堆栈 react-native-navigation V2 弹出第二个屏幕后如何刷新第一个屏幕?
- android - google play 控制台如何正确填写权限声明表?
- algorithm - 用孔捕获雨水 ii (LeetCode) (0)
- html - html 视频标签全屏控制在 Chrome 中无法正常工作
- sql - Oracle查询以根据另一列值选择不同的值
- c# - 与 jquery 中继器绑定的 asp.net core mvc 模型