在 TeamCity 构建脚本中使用百分号 [英] Using the percent sign in TeamCity build scripts

查看:57
本文介绍了在 TeamCity 构建脚本中使用百分号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置运行自定义命令行脚本的 TeamCity 构建过程.该脚本使用一个变量,因此它需要一个百分号(例如 %x).但是 TeamCity 对其属性使用百分号(例如 %build.number%),因此脚本中的百分号在运行时会被删除.

I am trying to set up a TeamCity build process that runs a custom command line script. The script uses a variable so it needs a percent sign (e.g. %x). But TeamCity uses percent signs for its properties (e.g. %build.number%), so the percent sign in the script gets removed when it runs.

如果脚本包含这个:

for /d %x in ("c:\*") do @echo "%x"

这是它实际运行的内容:

This is what it actually runs:

for /d x in ("\*") do @echo "x"

如何编写脚本以使其包含变量?

How can I write my script so it can include variables?

推荐答案

Try for/d %%x in ("c:\*") do @echo "%%x" (ie复制 % 符号).

Try for /d %%x in ("c:\*") do @echo "%%x" (i.e. duplicate the % signs).

但是应该有办法告诉TC不要管这个文件.如果 TC 删除源中的百分号,那将是可怕的.因此,我很确定您在配置中做了一些事情来启用 % 的替换.

But there should be a way to tell TC to leave the file alone. It would be horrible if TC would remove the percent signs in the sources. Therefore, I'm pretty sure that you did something in the configuration to enable replacement of %.

同样,是否真的是 TC 搞乱了脚本?或者您是否使用构建工具来生成脚本或类似的东西?

On a similar note, is it really TC that messes with the script? Or are you using a build tool to generate the script or something like that?

这篇关于在 TeamCity 构建脚本中使用百分号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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