Visual Studio Team Services说“ Task PowerShell失败”,尽管没有

pet*_*ter 5 git powershell continuous-integration azure-devops

在VS Team Services中的Powershell脚本结尾处出现以下错误:

任务PowerShell失败。这导致作业失败。查看任务的日志以了解更多详细信息。

但是,脚本没有失败。它完成了我想要做的所有事情。有什么办法可以向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
Run Code Online (Sandbox Code Playgroud)

该脚本将运行并正确执行所有操作。但是,这是我的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
******************************************************************************
Run Code Online (Sandbox Code Playgroud)

从此输出中,以下几行为红色,并且类似错误行:

Cloning into 'example-repo'...
Run Code Online (Sandbox Code Playgroud)

To BITBUCKET_URL/example-repo.git
b861c96..afd33e6 master -> master
Run Code Online (Sandbox Code Playgroud)

可能是这里返回0以外的任何东西,这就是VS Team Services“检测”失败的原因吗?

我该如何预防?

更新:

仅运行git clone已经表明存在错误,因此看起来git clone并且git push确实会导致某些问题被VS Team Services视为错误。

pet*_*ter 2

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

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

git clone --quiet ...
git push --porcelain ...
Run Code Online (Sandbox Code Playgroud)

阻止 git 报告 stderr 上的状态,并完全停止报告 ( --quiet) 或将其发送到 stdout ( --porcelain)。

更新:

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

git config core.safecrlf false
Run Code Online (Sandbox Code Playgroud)

当然,您可能还想core.autocrlf在配置中进行设置。