1

I am using VSTS to run protractor e2e test cases. I have a npm custom task that run the tests and even if the test fails, vsts build doesn't fail.

How can I make the vsts build fail?

user911
  • 1,509
  • 6
  • 26
  • 52

1 Answers1

3

You could try using Write-Error in combination with an exit 1 to fail a task:

Write-Error ("Some error")
exit 1

Check the case below:

How to fail the build from a PowerShell task in TFS 2015

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • I am already returning error code as 1. Why do I need to do this? Why VSTS can't understand the exit/error code return by npm task? – user911 Jul 02 '18 at 18:57
  • You could check [Task Logging Commands](https://github.com/Microsoft/vsts-tasks/blob/master/docs/authoring/commands.md), using `##vso[task.complete]current operation` to finish timeline record for current task, set task result and current operation. – Cece Dong - MSFT Jul 03 '18 at 09:16