git - Visual Studio Team Services 说 "Task PowerShell failed"虽然它没有

标签 git powershell continuous-integration azure-devops

我在 VS Team Services 中的 powershell 脚本末尾收到以下错误:

Task PowerShell failed. This caused the job to fail. Look at the logs for the task for more details.

但是,脚本并没有失败。它做了我想让它做的一切。我可以通过某种方式向 VS Team Services 解释这一点吗?

该脚本从 VS Team Services 获取经过编译和测试的代码,并将其推送到 bitbucket 上的 git 存储库。这样,我可以从中自动创建一个 docker 容器并更新我的应用程序。这是脚本:

git clone BITBUCKET_URL/example-repo.git
cd example-repo

echo "Clean app-folder and remove Dockerfile"

remove-item app -recurse -force
remove-item Dockerfile -force

new-item -name app -itemtype directory

echo "Copy new files into repository"

cp ../deploy/Dockerfile .
cp ../ExampleApp/bin/Debug/* ./app

echo "Set email, name and include all files"

git config user.email "EMAIL"
git config user.name "NAME"
git add -A

echo "What has changed:"
git status

echo "Commit and Push..."
git commit -m "VS Online Commit"
git push origin master

此脚本贯穿始终并正确执行所有操作。但是,这是我的 Visual Studio Team Services 日志的结尾:

******************************************************************************
Starting task: Powershell: deploy/deploy.ps1
******************************************************************************
Cloning into 'example-repo'...
Clean app-folder and remove Dockerfile
    Directory: C:\PROJECT\example-repo
Mode                LastWriteTime     Length Name                                                                      
----                -------------     ------ ----                                                                      
d----         7/17/2015   7:59 AM            app                                                                       
Copy new files into repository
Set email, name and include all files
What has changed:
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
    modified:   app/App.exe
    modified:   app/App.pdb
Commit and Push...
 VS Online Commit
 2 files changed, 0 insertions(+), 0 deletions(-)
To BITBUCKET_URL/example-repo.git
b861c96..afd33e6 master -> master
******************************************************************************
Finishing task: PowerShell
******************************************************************************
Task PowerShell failed. This caused the job to fail. Look at the logs for the task for more details.
******************************************************************************
Finishing Build
******************************************************************************

从这个输出中,以下行是红色的,与错误行类似:

Cloning into 'example-repo'...

To BITBUCKET_URL/example-repo.git
b861c96..afd33e6 master -> master

难道这里的某些东西返回的不是 0,这就是 VS Team Services“检测”失败的原因?

我怎样才能避免这种情况?

更新:

只运行 git clone 已经显示有错误,所以看起来 git clonegit push 确实会导致一些错误被 VS Team Services 视为错误。

最佳答案

作为Vesper在他的回答中写道,git 正在将输出发送到 stderr,VS Team Services 认为它​​因此而失败。

但是,仅仅重定向或忽略 stderr 对我来说似乎不是正确的解决方案。相反,您可以指定:

git clone --quiet ...
git push --porcelain ...

阻止 git 在 stderr 上报告状态,或者完全停止报告 (--quiet) 或将其发送到标准输出 (--porcelain)。

更新:

如果 git add 显示有关行尾的警告,您可以使用以下配置禁用它:

git config core.safecrlf false

当然,你可能还想在配置中设置core.autocrlf

关于git - Visual Studio Team Services 说 "Task PowerShell failed"虽然它没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31471270/

相关文章:

在分支之间快速切换的 git 最佳实践

git子模块跟踪最新

Git找到第一个非本地提交

powershell - 此语法有何作用 : | select @{E={$_. PSComputerName}; L ='Server' },名称,进程 ID,路径名?

c# - 如何为 Windows Phone 7 应用程序构建持续集成

git - 致命: unable to access 'https://github.com/usename/my-project.git/' : The requested URL returned error: 403 Mac

windows - 在 Powershell 中为另一本地用户登录时触发的一次性计划任务

powershell - 将某个目录中的所有函数加载到 PowerShell 中

continuous-integration - 即使构建步骤失败,如何继续Jenkins构建?

ruby-on-rails - 有没有办法从 Coveralls 测试覆盖率评分中免除文件/文件夹?