即使远程PowerShell脚本返回非零代码,发布定义也始终成功 [英] Release definition always success even if the remote powershell script returns non-zero code

查看:105
本文介绍了即使远程PowerShell脚本返回非零代码,发布定义也始终成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我的发布定义中的任务是"目标机器上的Powershell"。



调用以非零代码退出的远程PowerShell脚本不会将任务标记为失败,为什么?



我可以使用"Write-Error"而不是"退出"在我的脚本中,但在这种情况下,所有脚本命令输出都不再显示,所以它对我来说不是一个有效的选项。



任何想法或解决方法?

Hi,

I have the task 'Powershell on target machines' in my release definition.

Invoking a remote powershell script that exits with a non-zero code does not mark the task as failed, why?

I could use "Write-Error" instead of "Exit" in my script but in this case all the script commands outputs are not shown anymore, so it's not a valid option for me.

Any idea or workaround?

推荐答案

Juan Antonio Ortega Rejon,

Hi Juan Antonio Ortega Rejon,

感谢您在此发帖。

你能分享你的PowerShell脚本以便我们可以重现吗?

Could you share your PowerShell script so that we can reproduce?

通常你应该从脚本中获得返回错误代码,你可以使用"exit 0"获得成功并"退出1"对于失败。请参考

本文

此主题。

Commonly you should get the return error code from your script, you can use "exit 0" for success and "exit 1" for failures. Please reference this article and this thread.

您可以尝试在目标计算机任务中使用 PowerShell 任务而不是
'Powershell ,然后再次检查脚本。

And you can try using PowerShell task instead of the 'Powershell on target machines' task, then check the script again.

最诚挚的问候。


这篇关于即使远程PowerShell脚本返回非零代码,发布定义也始终成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆