Is there a way to fail a build when one of the build hooks throws an error?
Platform.sh DevRel
In my case I want to use npm clean-install instead of npm install to ensure that my package-lock and my package.json have not diverged.
0
Comments
Yes. To do this you need to start your build hook with
set -e. That means :To be a bit more clear, if you don’t use
set -e, the build will exit with the exit code of the last command.For example:
Will exit with exit code “0”, for success. If you use
set -e, the build will exit after thelswith the exit code thatlsfailed with.Another option that is usually useful is
set -o pipefailwhich will fail the build if a piped command fails.For example:
Will return with exit code 0.
Will return with a failure.
Please sign in to leave a comment.