Git VisualStudioTeamServices说;“任务PowerShell失败”;虽然没有';T

Git VisualStudioTeamServices说;“任务PowerShell失败”;虽然没有';T,git,powershell,continuous-integration,azure-devops,Git,Powershell,Continuous Integration,Azure Devops,在VS Team Services中,我的powershell脚本末尾出现以下错误: 任务PowerShell失败。这导致工作失败。查看任务的日志以了解更多详细信息 然而,脚本并没有失败。它做了我想做的一切。有什么方法可以向VS团队服务部解释吗 该脚本从VS Team Services获取编译和测试的代码,并将其推送到bitbucket上的git存储库。这样,我就可以从中自动创建docker容器并更新我的应用程序。以下是脚本: git clone BITBUCKET_URL/example-re

在VS Team Services中,我的powershell脚本末尾出现以下错误:

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

然而,脚本并没有失败。它做了我想做的一切。有什么方法可以向VS团队服务部解释吗

该脚本从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团队服务日志到此结束:

******************************************************************************
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
******************************************************************************

这里是否有返回0以外的任何内容,这就是VS团队服务“检测”故障的原因

我怎样才能防止呢

更新:


仅运行
git clone
已经表明存在错误,因此似乎
git clone
git push
确实会导致VS团队服务将其视为错误。

显然,Visual Studio在错误通道上的反应就像脚本出错一样。由于您的
git
将一些输出发送到错误通道,您可以将脚本与
2>&1
输出重定向器一起使用,或者将
$ErrorActionPreference
设置为脚本中的
silentlyContinue
,或者以相同的方式重定向所有
git
命令输出

关于退出代码-如果脚本不包含
exit
命令,则其退出代码为零,因为Powershell在解释脚本时会吸收所有
git
命令的退出代码,在每个命令后面的脚本中都可以作为
$lastExitCode
使用,但如果不使用,则会被删除。

正如他在回答中所说的,git正在向stderr发送输出,VS团队服务认为它因此失败

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

git clone --quiet ...
git push --porcelain ...
停止git在stderr上报告状态,并停止报告()或将其发送到stdout()

更新:

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

git config core.safecrlf false

当然,您可能还需要在配置中设置
core.autocrlf

thx以获取提示。我没有设法使用
2>&1
,但是,我想这是一个解决方案,而不是我提出的解决方案。关于命令参数的最终知识确实比一般解决方案要好。当然,如果可能的话。:)
git clone --quiet ...
git push --porcelain ...
git config core.safecrlf false