问题描述
我们正在Windows机器上运行Atlassian的Bamboo构建服务器4.1.2.我创建了一个在Task中执行的批处理文件.该脚本只是在.bat文件中引用,而不是在任务中内联. (例如createimage.bat)
We're running Atlassian's Bamboo build server 4.1.2 on a Windows machine. I've created a batch file that is executed within a Task. The script is just referenced in a .bat file an not inline in the task. (e.g. createimage.bat)
在createimage.bat中,我想使用Bamboo的PLAN变量.通常的变量语法无法正常工作,意味着无法替换.脚本中的一行可能是例如:
Within the createimage.bat, I'd like to use Bamboo's PLAN variables. The usual variable syntax is not working, means not replaced. A line in the script could be for example:
goq-image-${bamboo.INTERNALVERSION}-SB${bamboo.buildNumber}
有什么想法吗?
推荐答案
您正在使用内部 Bamboo变量语法,但是脚本任务会将它们传递到操作系统的脚本环境中,并且需要使用相应的语法,例如(请注意各术语之间的下划线):
You are using the internal Bamboo variables syntax, but the Script Task passes those into the operating system's script environment and they need to be referenced with the respective syntax accordingly, e.g. (please note the underscores between terms):
- Unix-
goq-image-$bamboo_INTERNALVERSION-SB$bamboo_buildNumber
- Windows-
goq-image-%bamboo_INTERNALVERSION%-SB%bamboo_buildNumber%
- Unix -
goq-image-$bamboo_INTERNALVERSION-SB$bamboo_buildNumber
- Windows -
goq-image-%bamboo_INTERNALVERSION%-SB%bamboo_buildNumber%
令人惊讶的是,我找不到Windows版本的正式参考,只有使用bash中的变量现在:
Surprisingly, I'm unable to find an official reference for the Windows variation, there's only Using variables in bash right now:
但是,我有时已经从Atlassian文档中找到了Windows语法,并按照 Bamboo中记录的方法对其进行了测试和使用.变量替换/定义:
However, I've figured the Windows syntax from Atlassian's documentation at some point, and tested and used it as documented in Bamboo Variable Substitution/Definition:
这篇关于批处理文件中的Bamboo变量替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!