teamcityteamcity-7.0

TeamCity 7.0.1 command line build step and ERRORLEVEL


I have a build step in my build configuration thats runner type "Command Line", running a custom script.

The script is executing Robocopy:

robocopy "%teamcity.build.workingDir%\Code" "\\target\d$\Web\Target Sites" /E /NP /LOG:robocopy.log

if ERRORLEVEL GEQ 4 (
"D:\blat.exe" "robocopy.log" -to me@me.com -f me@me.com -subject "Error during robocopy on TEAMCITY" -server mail.me.com
)

exit /B 0

The Robocopy command is working fine but I keep getting an email and in the build log I keep seeing:

GEQ was unexpected at this time.

The ERRORLEVEL check isn't working for some reason?

I tried IF %ERRORLEVEL% GEQ but this breaks my build has TeamCity expects me to pass a build parameter.

Does this only work as an "Executable with parameters"?


Solution

  • Neil, you might try escaping the percent sign.

    Try IF %%ERRORLEVEL%% GEQ ...