Interacting with system variables from command line (bash)

I'm working with bash, I've looked in the documentation and on the internet and it seems this is how your're supposed to be able to set variables in teamcity. but this is not working.

##teamcity[setParameter name='ddd' value='fff']
echo %ddd%
exit 0

In the build log I get a blank line and the %ddd% variable is empty on echo and enpty in the teamcity interface.

Am I using this wrong?

I'm ultimately attempting to set a variable in teamcity using date from bash shell.

Thanks in advance.

Comment actions Permalink


To set build parameters from command line you need to use the following commands:

Build Step #1:
echo "##teamcity[setParameter name='env.ddd' value='fff']"
echo "##teamcity[setParameter name='env.datetime' value='$(date)']"

The values of initialized parameters will be avaliable on the next build step:

Build Step #2:
echo $ddd
echo $datetime

Comment actions Permalink

I am having the same problem here, even when I try to access the variables in the next build step the data is not up to date. The first build step scripts looks like this:

##teamcity[setParameter name='env.MinorNumber' value='1']
##teamcity[setParameter name='MinorNumber' value='1']
##teamcity[setParameter name='system.MinorNumber' value='1']

the second build step script looks like this:

echo "MinorNumber% is %MinorNumber%"
echo "env.MinorNumber% is %env.MinorNumber%"
echo "system.MinorNumber% is %system.MinorNumber%"
echo "MinorNumber$ is $MinorNumber"

In all the cases the minor number is shown to be 0 or empty as set in the parameters page of the configuration and not 1. I am on the latest TC server 2018.2.3. Is this a bug or am I doing something wrong?


Comment actions Permalink

Ok I forgot I had to use echo to output the messages to the console, that solves it now


Please sign in to leave a comment.