Skip to content

Instantly share code, notes, and snippets.

@1syo
Last active December 26, 2015 04:44
Show Gist options
  • Save 1syo/eec8459952fb605639ba to your computer and use it in GitHub Desktop.
Save 1syo/eec8459952fb605639ba to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -ne 1 ]; then
echo 'Argumant error.'
exit 1
fi
repo=$1
header="Accept: application/vnd.travis-ci.2+json"
url="https://api.travis-ci.org/repos/${repo}/builds"
result=$(curl -s -H "${header}" ${url} | jq -r '.builds[0] | {id: .id, state: .state}')
id=$(echo ${result} | jq -r '.id')
state=$(echo ${result} | jq -r '.state')
echo "[build ${state}] ${repo}: https://travis-ci.org/${repo}/builds/${id}"
if [ $state = 'passed' ]; then
exit 0
else
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment