Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity conflict with % symbol in Command Line build step

Tags:

teamcity

I have a batch file that I use to copy a folder and it's contents to a new location, it also creates the folder name based on the date and time (and this works):

SET TODAY=%DATE:/=-%
SET NOW=%TIME::=-%
XCOPY /S /Y "C:\BuildAgent\temp\buildTmp" "C:\Automation Results\%TODAY%_%NOW%\" 

I added a new Configuration Step to my Team City setup, to include this batch file. The build step is a Command Line - Custom Script:

Build Step

But this has an adverse effect on the TC Agent Requirements and I cannot start my TC builds:

Agent Requirements

This issue seems to be related to TC Implicit Requirements:

http://confluence.jetbrains.com/display/TCD8/Agent+Requirements

"Implicit Requirements Any reference (name in %-signs) to an unknown parameter is considered an "implicit requirement". That means that the build will only run on the agent which provides the parameters named. Otherwise, the parameter should be made available for the build configuration by defining it on the build configuration or project levels."

How can I get around this TC conflict with % symbol which I need in my batch file?

like image 946
Benny Meade Avatar asked May 27 '14 10:05

Benny Meade


2 Answers

put the contents of your build script inside a file, eg copy.bat and call this batch file from TeamCity

Addtionally, change from Custom script to Executable with parameters

enter image description here

like image 113
wal Avatar answered Oct 15 '22 12:10

wal


Use %% instead of %

SET TODAY=%%DATE:/=-%%
SET NOW=%%TIME::=-%%
XCOPY /S /Y "C:\BuildAgent\temp\buildTmp" "C:\Automation Results\%%TODAY%%_%%NOW%%\"

This will ensure the variables are treated as batch file variables instead of TeamCity variables.

like image 23
infojolt Avatar answered Oct 15 '22 12:10

infojolt