批处理文件中的Bamboo变量替换 [英] Bamboo variable replacement in batch file

查看:111
本文介绍了批处理文件中的Bamboo变量替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在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:

Bamboo变量作为bash shell变量导出.所有句号 (句点)转换为下划线.例如,变量 Bamboo.my.variable在bash中为$ bamboo_my_variable.这与 文件脚本任务(不是内联脚本任务).

Bamboo variables are exported as bash shell variables. All full stops (periods) are converted to underscores. For example, the variable bamboo.my.variable is $bamboo_my_variable in bash. This is related to File Script tasks (not Inline Script tasks).

但是,我有时已经从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_custom_aws_cfn_stack_StringWithRegex(Unix)或 %bamboo_custom_aws_cfn_stack_StringWithRegex%(Windows)
  • these variables are also available as environment variables in the Script Task for example, albeit named slightly different, e.g. $bamboo_custom_aws_cfn_stack_StringWithRegex (Unix) or %bamboo_custom_aws_cfn_stack_StringWithRegex% (Windows)

这篇关于批处理文件中的Bamboo变量替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆