Last active
October 22, 2015 04:47
-
-
Save gabro/9f70e86f4349c014e64e to your computer and use it in GitHub Desktop.
Bambo <3 GitHub Status API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GITHUB_API=https://api.github.com | |
AUTH_TOKEN= # GITHUB API TOKEN HERE | |
REPO= # REPO NAME HERE | |
URL=${bamboo.buildResultsUrl} | |
SHA=${bamboo.repository.revision.number} | |
SUCCESS_DESCRIPTION="The Bamboo CI build passed" | |
FAILURE_DESCRIPTION="Build #${bamboo.buildNumber} failed" | |
# lol (mocha.json generated by mocha-bamboo-reporter) | |
FAILED_TESTS=`grep -o '"failures": \d\+' mocha.json | cut -f2 -d" "` | |
GITHUB_STATUS_ENDPOINT=$GITHUB_API/repos/$REPO/statuses/$SHA | |
if [ $FAILED_TESTS == 0 ]; then | |
curl -k -H "Authorization: token $AUTH_TOKEN" --request POST --data "{\"state\": \"success\", \"description\": \"$SUCCESS_DESCRIPTION\", \"target_url\": \"$URL\"}" $GITHUB_STATUS_ENDPOINT > /dev/null | |
else | |
curl -k -H "Authorization: token $AUTH_TOKEN" --request POST --data "{\"state\": \"failure\", \"description\": \"$FAILURE_DESCRIPTION\", \"target_url\": \"$URL\"}" $GITHUB_STATUS_ENDPOINT > /dev/null | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GITHUB_API=https://api.github.com | |
AUTH_TOKEN= # GITHUB API TOKEN HERE | |
REPO= # REPO NAME HERE | |
URL=${bamboo.buildResultsUrl} | |
SHA=${bamboo.repository.revision.number} | |
PENDING_DESCRIPTION="The Bamboo CI build is in progress" | |
GITHUB_STATUS_ENDPOINT=$GITHUB_API/repos/$REPO/statuses/$SHA | |
curl -k -H "Authorization: token $AUTH_TOKEN" --request POST --data "{\"state\": \"pending\", \"description\": \"$PENDING_DESCRIPTION\", \"target_url\": \"$URL\"}" $GITHUB_STATUS_ENDPOINT > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment