Reputation: 131
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?
Upvotes: 8
Views: 22573
Reputation: 5418
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%%\
Upvotes: 25
Reputation: 22824
Try creating a .bat file or Powershell file that accepts a parameter, and executes the steps you have outlined above.
Then switch your Build step to run an "executable with parameters", and pass the %VERSION% in as a parameter.
Upvotes: 0