[英]PowerShell script exit code transition from 3rd party tool to TeamCity
I have PowerShell script which lunches command-line tool 我有在命令行工具中使用午餐的PowerShell脚本
Set-Location "$env:HOMEDRIVE\Tool 1.0.6.5"
.\tool.exe $or $do 0
This tool has 4 types of exit codes - 0, 1, 2, 3. 此工具有4种退出代码-0、1、2、3。
When I run this script in TeamCity, exit code of the script is always zero (success). 当我在TeamCity中运行此脚本时,脚本的退出代码始终为零(成功)。 I would like to sent other exit codes and mark test as "fail" in case any of 1, 2, 3 exit codes present in TeamCity Build Log.
如果TeamCity构建日志中存在1、2、3个退出代码中的任何一个,我想发送其他退出代码并将测试标记为“失败”。
How can I catch and sent exit codes to TeamCity via PowerShell methods? 如何通过PowerShell方法捕获退出代码并将其发送给TeamCity?
Here is a solution (at least it works for the small script) 这是一个解决方案(至少适用于小脚本)
Set-Location "$env:HOMEDRIVE\Tool 1.0.6.5"
.\tool.exe $or $do 0
Write-Output "Exitcode $LASTEXITCODE"
What this script does: 该脚本的作用:
1) Set location to folder where tool placed 2) Start tool with parameters 3) Write an output directly to console 1)将位置设置为放置工具的文件夹2)使用参数启动工具3)直接将输出写入控制台
In TeamCity I have added 3 rules: 1) Build fails if build log contains text "Exitcode 1" 2) Build fails if build log contains text "Exitcode 2" 2) Build fails if build log contains text "Exitcode 3" 在TeamCity中,我添加了3条规则:1)如果构建日志包含文本“ Exitcode 1”,则构建失败2)如果构建日志包含文本“ Exitcode 2”,则构建失败2)如果构建日志包含文本“ Exitcode 3”,则构建失败
Also I have added text of failure message - it relates to exit code number and shows what has happened with build. 另外,我还添加了失败消息文本-它与退出代码号有关,并显示了构建过程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.