# Configure VSTS to properly abort in case of errors

Christian Hujer 09/03/2018. 1 answers, 43 views

Given the following .vsts-ci.yml file

queue: Hosted Linux Preview

steps:
- script: |
false
true

The expected behavior and the actual behavior differ.

Expected behavior: Build fails at the false command, true will not be executed.

Actual behavior: Build succeeds, true is executed after the false command.

Details:

I would expect the VSTS build to fail on the first command false. However, VSTS executes the second command true as well and reports success. This means that the shell is setup incorrectly for build systems. The correct setup would be to have pipefail and errexit set. But it seems that errexit is not set, and probably pipefail isn't set either.

Is there a way to get the correct behavior, that is, pipefail and errexit, within the YAML file, without using bash -c in the scripts section? I know I can easily workaround by just moving the command sequence into a shell script or Makefile, I just want to know if there is a configuration possibility to get the YAML file execute shell commands in a shell with errexit and pipefail set, preferably a bash shell.

Christian Hujer 09/04/2018.

It seems that the bash shell created by VSTS does not have the pipefail and errexit flags set. See the following issue on GitHub about this: https://github.com/Microsoft/vsts-agent/issues/1803

But they can be set within the YAML file, like this:

queue: Hosted Linux Preview

steps:
- script: |
set -e ; set -o pipefail
false
true