Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity Command Line Runner: Setting and using variables

Within a TeamCity project running on a windows agent, I would like to read the contents of a file and then create a directory based on the file contents.

Performing this operation as a command line build step seems logical. I have tried creating a local variable "VERSION" as well as a custom teamcity parameter, but I can't get either to work. It does not seem that windows cmd variables are playing nicely with the TeamCity defined env and system variables. I am using the following custom script:

echo "Distributing"
set VERSION=< component_version.txt
echo %VERSION%
echo "Copying files to dir \path\to\dir\%VERSION%\"
mkdir \path\to\dir\%VERSION%\

Any suggestions on how I can achieve this?

like image 625
bwallace Avatar asked May 07 '14 15:05

bwallace


1 Answers

You need to escape the variable with %% so it isn't treated as a TeamCity variable.

echo "Distributing"
set VERSION=< component_version.txt
echo %%VERSION%%
echo "Copying files to dir \path\to\dir\%%VERSION%%\"
mkdir \path\to\dir\%%VERSION%%\
like image 130
infojolt Avatar answered Sep 21 '22 18:09

infojolt