PowerShell 想在 TeamCity 中提示

PowerShell wants to prompt in TeamCity

我是 运行 一个 PowerShell 脚本,作为 TeamCity 中 post 构建步骤之一,有一次我试图创建一个空文件作为占位符后面的步骤。我开始使用的代码是:

New-Item $MyPathAndFileName -Force

这在我的 ISE 机器上运行良好。然而,在 TeamCity 中执行它会导致整个构建步骤(以及构建配置)失败,构建日志条目为:

Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.

然后我将代码附加到以下内容:

if((Test-Path $MyPathAndFileName) -ne 0)
    {Remove-Item $MyPathAndFileName -Force}
New-Item $$MyPathAndFileName -Force -Confirm:$false -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -InformationAction SilentlyContinue

总是 New-Item 行失败。

我的问题是我可以

a) 让 PowerShell 写出它试图显示的提示,这样我就可以找出问题所在?或者

b) 在没有提示的情况下创建新项目?

在这种情况下,我们的 TeamCity 服务器上的一个代理 运行 正在使用旧版本的 PowerShell,并且期望 -Type 参数命名为 "file"。这适用于该行,但随后该代理在处理 zip 文件的后续脚本行中遇到问题。

由于我们无法升级 PowerShell 版本,我们设置了一个临时 work-around 作为构建配置,代理要求命名成功 运行 构建所需的特定代理。

不过,bottom-line 是 PowerShell 在 TeamCity 服务器上执行并试图提示用户的问题。一种将提示写入Build Log的方法,方便智能fault-finding.

感谢您的回复。