I'm getting the following error at the end of my powershell script in VS Team Services:
Task PowerShell failed. This caused the job to fail. Look at the logs for the task for more details.
However, the script didn't fail. It did everything I wanted it to do. Is there some way I can explain that to VS Team Services?
The script takes the compiled and tested code from VS Team Services and pushes it to a git repository on bitbucket. This way, I can automatically create a docker container from it and update my application. Here is the script:
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
This script runs through and does everything correctly. However, this is the end of my Visual Studio Team Services log:
******************************************************************************
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
******************************************************************************
From this output, the following lines were red and similarly like the error line:
Cloning into 'example-repo'...
and
To BITBUCKET_URL/example-repo.git
b861c96..afd33e6 master -> master
Could it be that something here returns anything but 0 and that's why VS Team Services "detects" the failure?
How can I prevent that?
Update:
Running only git clone
already shows that there is an error, so it seems like git clone
and git push
would really cause something which is treated like an error by VS Team Services.
As Vesper wrote in his answer, git is sending output to stderr and VS Team Services thinks it failed because of that.
However, just redirecting or ignoring stderr doesn't seem like the right solution for me. Instead you can specify:
git clone --quiet ...
git push --porcelain ...
to stop git from reporting the status on stderr and either stop reporting it at all (--quiet
) or sending it to stdout (--porcelain
).
Update:
if git add
is showing warnings about line endings, you can disable it with the following config:
git config core.safecrlf false
Of course, you might also want to set core.autocrlf
in the configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With