使用 powershell 控制 teamcity 步骤

controlling teamcity steps using powershell

我有以下场景。

我在 teamcity 中的一个项目有 5 个构建步骤。我希望只有当分支是 master 时才执行第 5 步。如果分支不是 master,团队城市进程应该退出而不执行第 5 步。我可以通过 powershell 实现吗?

我认为唯一的方法是将 powershell 步骤作为第 5 步,它只检查当前分支 (%teamcity.build.branch%),如果不是主分支则出错,然后执行您想要的步骤运行 当前第 5 步作为第 6 步。

团队城市doesn't always like to fail if the powershell steps fail,尤其是当前版本之前的版本。

为了解决这个问题,我们使用 作为源脚本,但它假定您想要 运行 的脚本在源代码管理中:

& "%teamcity.build.checkoutDir%\Path\To\PowershellScript.ps1" "%teamcity.build.checkoutDir%" 
Write-Host "The result was of the previous script was " $LASTEXITCODE
Exit $LASTEXITCODE

链接的答案包含更多选项,具体取决于您使用的版本,因此我假设您可以找到确切的方法来阻止构建失败。