如果 PostDeploy Powershell 脚本失败,则强制 Octopus Deploy 步骤失败
Force Octopus Deploy step to fail if PostDeploy Powershell script fails
在我的 Octopus 部署步骤之一中,我有一个名为 PostDeploy.ps1
的 Powershell 脚本可以正常运行,除了如果它遇到异常,部署会继续,就好像它成功了一样。
我看过一些关于 powershell 退出代码问题的帖子,但我找不到针对 PostDeploy 脚本特定问题的解决方案。
如果 PostDeploy 遇到错误,如何强制将步骤标记为失败?
您应该能够通过 $LastExitCode
非零和 Exit 1
.
的组合失败
夫妇用谷歌搜索链接:
- http://help.octopusdeploy.com/discussions/problems/7604-deploy-wont-fail-when-powershell-script-fails
- http://help.octopusdeploy.com/discussions/questions/4539-need-to-mark-a-step-as-failed
- http://help.octopusdeploy.com/discussions/problems/18419-octopus-powershell-step-doesnt-display-error
P.S。我相信你知道,但只是提醒一下,Octopus 中的一个版本正在快照变量、脚本、包等的版本。因此需要创建一个新版本 and/or 个包。
示例代码
$exePath=$OctopusParameters["Octopus.Action[mydeploystep].Output.Package.InstallationDirectoryPath"] + "\myapp.exe"
& $exePath
if ($LASTEXITCODE -ne 0)
{
EXIT 1
}
在我的 Octopus 部署步骤之一中,我有一个名为 PostDeploy.ps1
的 Powershell 脚本可以正常运行,除了如果它遇到异常,部署会继续,就好像它成功了一样。
我看过一些关于 powershell 退出代码问题的帖子,但我找不到针对 PostDeploy 脚本特定问题的解决方案。
如果 PostDeploy 遇到错误,如何强制将步骤标记为失败?
您应该能够通过 $LastExitCode
非零和 Exit 1
.
夫妇用谷歌搜索链接:
- http://help.octopusdeploy.com/discussions/problems/7604-deploy-wont-fail-when-powershell-script-fails
- http://help.octopusdeploy.com/discussions/questions/4539-need-to-mark-a-step-as-failed
- http://help.octopusdeploy.com/discussions/problems/18419-octopus-powershell-step-doesnt-display-error
P.S。我相信你知道,但只是提醒一下,Octopus 中的一个版本正在快照变量、脚本、包等的版本。因此需要创建一个新版本 and/or 个包。
示例代码
$exePath=$OctopusParameters["Octopus.Action[mydeploystep].Output.Package.InstallationDirectoryPath"] + "\myapp.exe"
& $exePath
if ($LASTEXITCODE -ne 0)
{
EXIT 1
}