无法在 TeamCity 中执行 Powershell 脚本

Unable to Execute Powershell Script in TeamCity

我在 TeamCity 中创建了一个 Powershell Build Runner 以 运行 以下代码:

<# 
    Steps to run:
    1) Login to Azure
    2) Select correct subscription
    3) Alter the path below to where you have the have saved the pester test locally
#>

$pesterParamters = @{
    Path       = '**.ps1 => pesterproject2.%build.number%.zip'
    Parameters = @{
                     templateUri                 = "**.json => pesterproject2.%build.number%.zip"
                     templateParameterObject     = @{
                            resourcePrefix = "pester"
                            adminPassword  = "Patters0n1234"
                        }
                  } 
}

$parameterHash= @{
                     resourcePrefix = "pester"
                     adminPassword  = "Patters0n1234"
                 }

Invoke-Pester -Script $pesterParamters -OutputFile "+:*/*.Xml =>
pesterproject2.%build.number%.zip" -OutputFormat NUnitXml -PassThru

然而,没有任何内容作为 .xml

被发送到输出 file/folder

如有任何想法,我们将不胜感激。

谢谢

彼得

您的 Invoke-Perster -OutputFile 语法似乎不正确。

您似乎想混合使用 Powershell 代码和 TeamCity 配置。

您应该将代码修改为:

Invoke-Pester -Script $pesterParamters -OutputFile "MyOutput.Xml" -OutputFormat NUnitXml -PassThru

在 TeamCity 的 Artifact paths 中,您应该设置:

*.xml => pesterproject2.%build.number%.zip