I must be doing something differently than what was asked and answered here because the solution does not appear to be working for me: TeamCity, passing an id generated in o
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.
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).
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.