12

我的构建配置中有一个构建步骤,即运行器类型“命令行”,运行自定义脚本。

该脚本正在执行 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

Robocopy 命令运行良好,但我不断收到一封电子邮件,并且在构建日志中我不断看到:

GEQ 在这个时候是出乎意料的。

ERRORLEVEL 检查由于某种原因不起作用?

我试过IF %ERRORLEVEL% GEQ了,但这破坏了我的构建,TeamCity 希望我传递一个构建参数。

这是否仅作为“带参数的可执行文件”工作?

4

2 回答 2

28

尼尔,您可以尝试转义百分号

尝试IF %%ERRORLEVEL%% GEQ ...

于 2013-02-07T16:34:29.933 回答
0

我刚刚遇到了这个问题,并感谢@John 的回答。

这是我想出的:

robocopy [from] [to] /MIR

REM http://ss64.com/nt/robocopy-exit.html
IF %%ERRORLEVEL%% EQU 0 (
   ECHO No errors occurred, and no copying was done; The source and destination directory trees are completely synchronized.
  EXIT 0
)
IF %%ERRORLEVEL%% EQU 1 (
  ECHO One or more files were copied successfully, new files have arrived.
  EXIT 0
)
 IF %%ERRORLEVEL%% EQU 2 (
  ECHO Some Extra files or directories were detected. No files were copied.
  EXIT 0
 ) 
IF %%ERRORLEVEL%% GEQ 3 (
  ECHO Robocopy Exit Codes: http://ss64.com/nt/robocopy-exit.html  
  EXIT %%ERRORLEVEL%%
)
于 2015-04-10T19:19:49.300 回答