I am writing a bash script to automate the build process. There are two major build blocks, one is an ant task and one is a plain old
mvn clean install. I want to do something when there is build error coming from either of this two build processes.
The problem is, these builds will contain test failures or errors from time to time, but the end result is successful. And I believe that the status code ($?) return by these processes should be 0 no matter the build fail or succeed, I could be wrong.
So what is the best way for my script to detect the end result (build fail/succeed) without catching the false info during the mid build (test errors, etc) from them?
mvn clean test if [[ "$?" -ne 0 ]] ; then echo 'could not perform tests'; exit $rc fi
$?is a special shell variable that contains the exit code (whether it terminated successfully, or not) of the most immediate recently executed command.
-nestands for "not equal". So here we are testing if the exit code from
mvn cleanis not equal to zero.