Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell Jenkins构建成功,即使PS脚本无法执行_Powershell_Jenkins - Fatal编程技术网

Powershell Jenkins构建成功,即使PS脚本无法执行

Powershell Jenkins构建成功,即使PS脚本无法执行,powershell,jenkins,Powershell,Jenkins,我正在执行Jenkins作业,该作业构建我的.csproj文件并执行几个PS脚本。 问题是,即使我的PS脚本失败,我也会收到一封成功的电子邮件,如果PS脚本失败,我应该如何告诉我的Jenkins工作人员也会触发我的电子邮件 错误日志- Copy-Item : The process cannot access the file '\\10.0.1.190\d$\Build\RPC\abcde.RPC.AirSearch\Common.Logging.Core.dll' because it i

我正在执行Jenkins作业,该作业构建我的.csproj文件并执行几个PS脚本。 问题是,即使我的PS脚本失败,我也会收到一封成功的电子邮件,如果PS脚本失败,我应该如何告诉我的Jenkins工作人员也会触发我的电子邮件

错误日志-

Copy-Item : The process cannot access the file 
'\\10.0.1.190\d$\Build\RPC\abcde.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\abcde.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/abcdeHoldings/abcde.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: abcde@software.com abcde@software.com abcde@software.com abcde@software.com
Finished: SUCCESS

有一个选项“附加构建日志”。您可以阅读构建日志以查看ps脚本是否失败

最简单的方法是将Jenkins配置为发送失败版本的电子邮件,并在Powershell步骤的末尾添加以下内容:

if ($error) { exit 1 }

Jenkins Powershell插件的问题在于,它不尊重Powershell中发生的错误,只尊重外壳本身的退出代码,这将迫使构建失败并触发电子邮件。

除了此之外,我是否还有其他解决方案,因为我已经设置了此解决方案。这不是问题的答案@B检查我的答案,应该会有帮助