Command Line runner doesn't honor errorlevel

Hello,

I'm finding that the command line runner doesn't honor the ERRORLEVEL variable.

I have a runner type of Command Line

With run set to "custom script"

And the custom script set to

 

----------

ROBOCOPY %DbBuild.robocopy.retry% .\Release\ %build.artifact.path%\ *.sql

ECHO %%ERRORLEVEL%%

----------

This ALWAYS returns a error level of 0 from the command runner, and a value of 1 from the CLI.

I've done other tests too, such as tweaking directory permission to cause a copy error, at which point the TC command runner copies nothing and presents an error level of 0 but from the CLI I get error level 8.

Is TC shadowing the errorlevel variable? How would I get this to work correctly?

 

******************************************************************************
07/19/2017 Update
******************************************************************************
Additional results.

I tried a differrent test and it works under this scenario.

I created a new build config that has one build step in it. A command line runner that executes the contents of the parameter TESTME.

When I run this it allows me to enter commands for the TESTME parameter that will in turn be executed in the command line runner.

When I execute THIS build configuration. The ERRORLEVEL value is correct.

For example I entered

----------------------------------------------------------------------
echo %%ERRORLEVEL%%
robocopy c:\invalid-not-exist c:\temp * /r:2 /w:10
echo Results are: %%ERRORLEVEL%%
----------------------------------------------------------------------

for TESTME and when it ran it correctly gave the expected output. Starts with ERRORLEVEL 0, runs robocopy, and then presents the error results of 16.

How does the command-line runner interact with the rest of the build steps?

 

******************************************************************************
07/19/2017 Update #2
******************************************************************************

AAARRGGGHH!! I greatly dislike inconsistent results. The problem is no longer reproducible!

0
1 comment

Hi John,

I'm glad that it works now. Maybe it didn't work earlier for some typo or something like that? One of the issues you might be experiencing is the fact that the % symbol is reserved in teamcity to handle its parameters. If you missed any of the % symbols that might have led to issues.

If you manage to replicate the issue again, please report it back so we can try to figure out what's going on.

0

Please sign in to leave a comment.