【发布时间】:2021-02-03 07:25:31
【问题描述】:
我正在尝试构建一个控制 Azure 中的 Windows 虚拟机的 Jenkins 管道。我需要使用 Azure CLI 在该 VM 上运行一些 Powershell 脚本。我遇到的问题是,即使 PowerShell 脚本失败,Azure CLI 也会成功返回操作。
这是脚本失败且管道通过时的运行:
{
"value": [
{
"code": "ComponentStatus/StdOut/succeeded",
"displayStatus": "Provisioning succeeded",
"level": "Info",
"message": "Uninstalling the previous version\n\nCheck that the previous installer was uninstalled\n\n'App' NOT is installed.\n",
"time": null
},
{
"code": "ComponentStatus/StdErr/succeeded",
"displayStatus": "Provisioning succeeded",
"level": "Info",
"message": "C:\\Location\\clean_up.ps1 : Exception of type \n'Microsoft.PowerShell.Commands.WriteErrorException' was thrown.\nAt C:\\Packages\\Plugins\\Microsoft.CPlat.Core.RunCommandWindows\\1.1.5\\Downloads\\script49.ps1:1 char:1\n+ & C:\\Location\\clean_up.ps1\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException\n + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,clean_up.ps1\n ",
"time": null
}
]
}
我无法找到任何方法将错误从 PowerShell 返回到管道,从而导致管道无法使用。有什么办法可以让 Jenkins Pipeline 失败吗?
【问题讨论】:
标签: azure powershell jenkins