Skip to content

Commit

Permalink
travis-build.sh: improve exit code checking
Browse files Browse the repository at this point in the history
This way, if a build step fails, we still continue, but record the
bad exit code. And then ultimately we fail the build accordingly.
  • Loading branch information
ctrueden committed May 23, 2018
1 parent f43b3bd commit 29b60a6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions travis-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

dir="$(dirname "$0")"

success=0
checkSuccess() {
# Log non-zero exit code.
test $1 -eq 0 || echo "==> FAILED: EXIT CODE $1" 1>&2

# Record the first non-zero exit code.
test $success -eq 0 && success=$1
}

# Build Maven projects.
if [ -f pom.xml ]
then
Expand Down Expand Up @@ -75,6 +84,7 @@ EOL
echo
echo "== Decrypting GPG keypair =="
openssl aes-256-cbc -K "$key" -iv "$iv" -in "$keyFile.enc" -out "$keyFile" -d
checkSuccess $?
fi
if [ "$TRAVIS_SECURE_ENV_VARS" = true \
-a "$TRAVIS_PULL_REQUEST" = false \
Expand All @@ -83,6 +93,7 @@ EOL
echo
echo "== Importing GPG keypair =="
gpg --batch --fast-import "$keyFile"
checkSuccess $?
fi

# Run the build.
Expand All @@ -93,20 +104,20 @@ EOL
echo
echo "== Building and deploying master SNAPSHOT =="
mvn -B -Pdeploy-to-imagej deploy
success=$?
checkSuccess $?
elif [ "$TRAVIS_SECURE_ENV_VARS" = true \
-a "$TRAVIS_PULL_REQUEST" = false \
-a -f release.properties ]
then
echo
echo "== Cutting and deploying release version =="
mvn -B release:perform
success=$?
checkSuccess $?
else
echo
echo "== Building the artifact locally only =="
mvn -B install javadoc:javadoc
success=$?
checkSuccess $?
fi
echo travis_fold:end:travis-build.sh-maven
fi
Expand Down

0 comments on commit 29b60a6

Please sign in to comment.