Azure Web 应用部署会导致 VS Team Services 中的 PowerShell 失败



我正在使用VS Team Services提供的CI来构建Web应用程序并部署到Azure。它基本上使用下面描述的"本地 git 存储库"方法:https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/

我使用 PowerShell 脚本运行部署,如下所示:

$sourcePath = Get-Location
cd ..
mkdir deploy
cd deploy
$deployPath = Get-Location
git init
git config core.safecrlf false
git remote add azure <fill-in>
git pull azure master --quiet
git rm -rf .
git clean -fxd
git reset
Copy-Item $sourcePath* $deployPath -Recurse
git add -A
git commit -m "Deploy"
git push azure master --porcelain

我注意到的是,几个 git 操作(如推送和拉取)会导致 PowerShell 看到错误(即使操作成功)。这就是为什么我使用"安静"和"瓷器"选项的原因。

现在棘手的部分是,在推送操作之后,Azure将自动运行一些部署脚本。这会导致 PowerShell 看到错误,即使操作成功,并且...我没有办法控制这一点。

如何让PowerShell正确识别真正的错误?

顺便说一句,如果您看到更好或更有效的方法,我很乐意了解它。

尝试使用以下格式调用 git 命令:

git pull 2>&1 | Write-Host

有关详细信息,请参阅 Pascal Berger 在此问题中的回答:Visual Studio Online Build 将 git 输出视为错误

相关内容

最新更新