[英]How to use Jenkins environment variable in shell script?
I want to update a java file with the jenkins build number. 我想用jenkins内部版本号更新一个java文件。 I plan on using a shell script to sed the value to the correct build number.
我计划使用shell脚本将值sed到正确的内部版本号。 I'm currently doing this:
我现在正在这样做:
sed -i 's/Version 3.0/Version $BUILD_DISPLAY_NAME/g'
/var/lib/jenkins/jobs/AndroidTest/workspace/xxx/res/values/strings.xml
Why doesn't this work? 为什么这不起作用? I'd assume I could just use them directly.
我想我可以直接使用它们。
As shellcheck would tell you, expansions don't happen in single quotes. 正如shellcheck会告诉你的那样,扩展不会发生在单引号中。 Use double quotes instead:
改为使用双引号:
sed -i "s/Version 3.0/Version $BUILD_DISPLAY_NAME/g" /var/lib/jenkins/jobs/AndroidTest/workspace/xxx/res/values/strings.xml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.