【问题标题】:Azure web app deployment cause PowerShell failure in VS Team ServicesAzure Web 应用程序部署导致 VS Team Services 中的 PowerShell 失败
【发布时间】:2016-06-13 16:55:04
【问题描述】:

我正在使用 VS Team Services 提供的 CI 来构建 Web 应用程序并部署到 Azure。它本质上使用这里描述的“本地 git repo”方法: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 操作,如 push 和 pull 会导致 PowerShell 看到错误(即使操作成功)。这就是我使用“安静”和“瓷器”选项的原因。

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

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

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

【问题讨论】:

  • 您是从 VSTS 构建还是发布运行 powershell 脚本?
  • 我从 VSTS Build 运行它。
  • 你试过链接中的解决方案了吗?
  • 是的。看起来它有效。谢谢。

标签: git powershell azure web azure-devops


【解决方案1】:

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

git pull 2>&1 | Write-Host

有关详细信息,请参阅 Pascal Berger 在此问题中的回答:Visual Studio Online Build treats git output as errors

【讨论】:

    猜你喜欢
    • 2017-06-01
    • 1970-01-01
    • 2023-02-02
    • 1970-01-01
    • 2018-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-08
    相关资源
    最近更新 更多