Powershell 正在失败 bamboo 任务,因为 -ExecutionPolicy bypass -Command return code 是 134 而不是 0

Powershell is failing bamboo task because -ExecutionPolicy bypass -Command return code is 134 instead of 0

我在 Bamboo 中有一个 运行 的 powershell 脚本,它将更新 Bamboo 构建的状态。这在 Github 中调用,然后状态将更新调用脚本的任何构建。这目前在 windows machine 中运行良好,但现在在 Mac machine 中需要构建。

首先,脚本是 return 错误代码 -1,因为我没有在 Mac 上安装 powershell。现在我已经安装了 powershell,但出现以下错误:

Failing task since return code of [powershell -ExecutionPolicy bypass -Command /bin/sh /var/folders/c6/T/MAC-CUSAPP-JOB1-14-ScriptBuildTask.ps1] was 134 while expected 0

代码本身对于 windows 没有问题,因为在 bamboo 上使用 windows 代理的所有其他构建都将成功构建任务。

& "${bamboo.build.working.directory}\scripts\publish-status.ps1" `
    -repoName MyRepo `
    -status pending `
    -revision ${bamboo.repository.revision.number} `
    -buildUrl ${bamboo.buildResultsUrl} `
    -description "Bamboo has started a build" `
    -context "bamboo-build"

有没有办法正确地做到这一点,以便它适用于 Mac。目前我已经检查过windows machine in 运行ning Powershell Version 5.0.0+ while Mac is Powershell 6.0.0 Alpha 这就是它的原因没有构建并给出错误代码 134?

当我什至尝试这样做时:

if (2 -lt 3)
{
 Write-Host this is lower
}
else
{
 Write-Host this is higher
}

它会给出相同的响应,即使我写了 Write-Host hello,它也会用 return 代码 134 响应。

即使使用一个简单的 powershell 脚本说 return 0 仍然会给出 return 代码为 134 的错误消息。我还检查了 machine 的 ExecutionPolicy 和一切都不受限制。

此外,问题不在于 Mac 上的 powershell,因为它会成功 运行 一个完美的 powershell 脚本,但问题是 bamboo 如何在 Mac 上使用 powershell 脚本.在使用 Mac 时,在 bamboo 上使用 powershell 脚本时是否需要做一些不同的事情?

这是我如何 运行 Bamboo 的图像,它是 windows 上需要的脚本任务,但这不适用于 mac。 更新

我将 powershell 添加为可执行文件,然后使用命令任务调用 powershell 文件,但这仍然不起作用,任何想法是不是因为 Bamboo 在 mac 上不支持 powershell 作为 powershell 工作正在使用visual studio代码和终端就mac。我这样做有两种方式:

-ExecutionPolicy Bypass -File /Users/dev/Documents/PowreshellScripts/hello.ps1

还有这样的:

-NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass -File /Users/dev/Documents/PowreshellScripts/hello.ps1

我粗略地 Google 这个问题,看起来这实际上是 Linux(和代理的 MacOS)的 PowerShell 的一个错误,至少根据 PowerShell for Mac GitHub issue I managed to find for it。报告 PowerShell 问题的用户在从 Linux 发行版 (Ubuntu?) 调用 PowerShell 脚本时似乎与 -ExecutionPolicy 参数有非常相似的问题,我认为这会推断出到 MacOS 由于 UNIX 架构。

从添加的评论来看,这似乎已在 Alpha Build 18 中得到修复。如果在使用最新版本的 PowerShell 的 MacOS 上仍然无法正常工作,我可能建议您在 PowerShell 上报告它GitHub 就像这个用户所做的那样:)