Teamcity SetParameter似乎不起作用 [英] Teamcity SetParameter doesn't seem to be working

查看:94
本文介绍了Teamcity SetParameter似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为构建配置的第一步,我试图动态更改参数并在后续步骤中使用它。在线阅读时,似乎要这样做是调用 ## teamcity [setParameter 。但这似乎不起作用。它甚至不会在同一步骤中更改值。

As the first step in a build configuration I am trying to dynamically change a parameter and use it in the subsequent steps. Reading online, it seems that the way to do this is to call ##teamcity[setParameter. But this doesn't seem to be working. It doesn't even change the value in the same step.

例如,我创建了一个测试参数并将其默认值设置为 1。在powershell脚本中,我尝试将其更改为2,如下所示。

For example, I have created a test parameter and set it's default value to '1'. Inside a powershell script, I tried to change it to 2, as shown below.

但是输出保持不变,如下所示。

But the output remains unchanged as can be seen below

我当前正在使用TeamCity 8.0.3(内部版本27540)。我究竟做错了什么?

I am currently using TeamCity 8.0.3 (build 27540). What am I doing wrong?

推荐答案

编辑:我认为问题可能出在您用来设置参数的命令上。尝试:

EDIT: I think the problem might be the command you're using to set the parameter. Try:

Write-Host "##teamcity[setParameter name='TestParameter' value='2']"

-

我们经历了相同的行为。这里的关键是 后续步骤。 您必须在运行之前单独构建步骤中修改参数。我想知道要使用新参数。

We've experienced the same behavior. The key here is 'subsequent steps.' You must modify the parameter in a separate build step that is run before the step in which you want to use the new parameter.

据我了解,构建步骤中的所有参数都将在执行该步骤之前立即进行评估。令牌将被这些参数的未修改值替换。因此,构建代理实际执行的操作是:

It's my understanding that all parameters in a build step are evaluated immediately before the execution of that step. The tokens will be replaced with the unmodified values of those parameters. Thus, what actually gets executed by the build agent is:

Write-Host "TestParameter value is 1"
Write-Host "##teamcity[setParameter name='TestParameter' value='2']"
Write-Host "TestParameter value is 1"

这篇关于Teamcity SetParameter似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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