How to cancel deployment if any part of the build fails or throws an error?
I set up a tiny build script for my site at https://github.com/ReactFinland/future-frontend-site/blob/main/build.sh . The question is, how can I cancel the current deployment if any part of the script throws an error? Right now that's resulting in semi-working deploys that may be missing files.
GitHub
future-frontend-site/build.sh at main · ReactFinland/future-fronten...
Contribute to ReactFinland/future-frontend-site development by creating an account on GitHub.
3 Replies
i think i'll try something along
|| exit 1
https://stackoverflow.com/questions/30078281/raise-error-in-a-bash-scriptStack Overflow
Raise error in a Bash script
I want to raise an error in a Bash script with message "Test cases Failed !!!". How to do this in Bash?
For example:
if [ condition ]; then
raise error "Test cases failed !!!"
fi
https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#The-Set-Builtin
set -e is what you're looking for
Bash Reference Manual
Bash Reference Manual
nice, that's even better than spamming
exit 1
(which seems to work)
it would be cool if you could add a recipe with these sort of tricks to the docs