My question is partially answered here: gitlab ci scripts during which $? is allowed to be non-zero
In principle, I want to achieve the following in bash:
// assume both functions return truthy values and the 2nd doesn't run if 1st fails
$success = test1() && test2();
someOtherStuff();
exit($success);
GitLab CI scripts terminate immediately when any simple command fails (possibly due to set -e, IDK for sure).
The nearest (and taking that link into consideration):
CODE=0
if test1 && test2; then
CODE=1
fi
someOtherStuff
exit $CODE
Is there any better way? In particular, I'd like to get the real $CODE not a fake one.
set -eis not particularly good practice -- see BashFAQ #105.BEHAT_PARAMSetc) and vars for local use.set -eoff by puttingset +ein your script.