我正在执行Jenkins Job,它构建我的.csproj文件并执行一些PS脚本。 问题是,即使我的PS脚本失败,我也会收到一封成功的电子邮件。如果PS脚本失败,我该如何告诉我的Jenkins Job也会触发我的电子邮件。
错误日志 -
Copy-Item : The process cannot access the file
'\\10.0.1.190\d$\Build\RPC\Fortius.RPC.AirSearch\Common.Logging.Core.dll' because it is being used by another process.
At C:\Users\Administrator\AppData\Local\Temp\hudson9059014122834846757.ps1:3 char:1
+ Copy-Item "C:\AirSearchBnd\src\Fortius.Air.Search.RPC.Host\bin\Release\*" "\\$en ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
[AirSearchBnd] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\ADMINI~1\AppData\Local\Temp\hudson9149103993066004448.ps1'"
[SC] CreateService SUCCESS
SERVICE_NAME: AirSearchWindowsService
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
PID : 13784
FLAGS :
> C:\Program Files (x86)\Git\bin\git.exe tag -l RPCBUILD_6 # timeout=10
> C:\Program Files (x86)\Git\bin\git.exe tag -a -f -m Jenkins Git plugin tagging with RPCBUILD_6 RPCBUILD_6 # timeout=10
Pushing tag RPCBUILD_6 to repo Dev
> C:\Program Files (x86)\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
> C:\Program Files (x86)\Git\bin\git.exe push https://github.com/WorldVenturesHoldings/Fortius.Services.Air.Search.git RPCBUILD_6
Email was triggered for: Always
Sending email for trigger: Always
Request made to compress build log
Sending email to: rajani.rk@sonata-software.com satyanarayana.r@sonata-software.com hariharachandan.g@sonata-software.com kalyan.bs@sonata-software.com
Finished: SUCCESS
答案 0 :(得分:2)
最简单的方法是将Jenkins配置为在失败的构建上发送电子邮件,并在Powershell步骤中添加以下内容:
if ($error) { exit 1 }
Jenkins Powershell插件的问题在于它并不承认Powershell中发生的错误,只是shell本身的退出代码,这将迫使构建失败并触发电子邮件。
答案 1 :(得分:0)
有一个"附加构建日志"的选项。如果ps脚本失败,您可以阅读构建日志以查看。