Benny Meade
Benny Meade

Reputation: 612

TeamCity conflict with % symbol in Command Line build step

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?

Upvotes: 10

Views: 8213

Answers (2)

infojolt
infojolt

Reputation: 5418

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.

Upvotes: 13

wal
wal

Reputation: 17729

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

Upvotes: 3

Related Questions