Skip to content

Commit

Permalink
Fix travis_fastfail.sh for null case
Browse files Browse the repository at this point in the history
when an old PR build gets restarted after some time, the travis API request
might not return enough builds to include the most recent one for the PR,
so the null result would incorrectly cause a 'superceded' fast-fail condition
  • Loading branch information
tkelman committed Dec 5, 2015
1 parent d7fc5d8 commit 111f5e5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions contrib/travis_fastfail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ curlhdr="Accept: application/vnd.travis-ci.2+json"
endpoint="https://api.travis-ci.org/repos/$TRAVIS_REPO_SLUG"

# Fail fast for superseded builds to PR's
if ! [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
if ! [ \"$TRAVIS_BUILD_NUMBER\" = $(curl -H "$curlhdr" $endpoint/builds?event_type=pull_request | \
jq ".builds | map(select(.pull_request_number == $TRAVIS_PULL_REQUEST))[0].number") ]; then
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
newestbuildforthisPR=$(curl -H "$curlhdr" $endpoint/builds?event_type=pull_request | \
jq ".builds | map(select(.pull_request_number == $TRAVIS_PULL_REQUEST))[0].number")
if [ $newestbuildforthisPR != null -a $newestbuildforthisPR != \"$TRAVIS_BUILD_NUMBER\" ]; then
echo "There are newer queued builds for this pull request, failing early."
exit 1
fi
Expand All @@ -17,7 +18,7 @@ else
master | release*)
;;
*)
if ! [ \"$TRAVIS_BUILD_NUMBER\" = $(curl -H "$curlhdr" \
if [ \"$TRAVIS_BUILD_NUMBER\" != $(curl -H "$curlhdr" \
$endpoint/branches/$TRAVIS_BRANCH | jq ".branch.number") ]; then
echo "There are newer queued builds for this branch, failing early."
exit 1
Expand Down

0 comments on commit 111f5e5

Please sign in to comment.