TeamCity - using setParameter to pass information between build steps

痞子三分冷 提交于 2019-11-29 23:05:43

you need to echo that string, e.g.

echo "##teamcity[setParameter name='env.TEST' value='test']"

What I found is that with long values, as soon as TeamCity is breaking down the log output into two separate lines echo will not work anymore - you have to use Write-Host instead.

Write-Host "##teamcity[setParameter name='env.TEST' value='test']"

This should always work, just a side note - this value will be available only on subsequent build steps.

I think you have an extra "\" in there. Try removing that and add double quotes around it and it should work.

 "##teamcity[setParameter name='env.TEST' value='test']"

If it doesn't work try using Powershell runner type as I'm using that for setting it and it works.

To expand on the above answers, with powershell it would look like so in build step 1:

Write-Host "##teamcity[setParameter name='env.TEST' value='$test']"

...and you can use the value like this in step 2:

echo %env.Test%

Also as a note, you'll have to set env.Test in the TC build parameters to be equal to something. I just used a space since I know the value will be set via ps script. Hope this helps.

It has to be printed to STDOUT, I use cat with heredoc to avoid having to escape single quotes in the event of using variables to dynamically set config parameters. What is heredoc?

MYVARNAME=MYVALUE
cat <<EOF
##teamcity[setParameter name='myConfParameter' value='$MYVARNAME']
EOF

Result:

##teamcity[setParameter name='myConfParameter' value='MYVALUE']

Documentation

Here is official ticket about addition double quotes and echo (Write-Host - OS dependency).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!