Created
June 9, 2012 16:33
-
-
Save coffeejunk/2901684 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# | |
# this script adds a comment with the current build status to a commit on github | |
# | |
# you have to set the environment variable $GH_TOKEN with your github oauth token, | |
# $JANKY_SHA1 will be set by janky. | |
# | |
# run: `./jenkins_github_comment.sh 0 user/repository` for a passing build and | |
# `./jenkins_github_comment.sh 1 user/repository` for a failing build | |
if [[ -z $1 || -z $2 ]]; then | |
echo "usage: ./jenkins_github_comment.sh (0,1) user/repository" | |
exit 1 | |
elif [ -z $GH_TOKEN ]; then | |
echo "please set \$GH_TOKEN" | |
exit 1 | |
elif [ -z $JANKY_SHA1 ]; then | |
echo "please set \$JANKY_SHA1" | |
exit 1 | |
fi | |
PROJ_ORIGIN=$2 | |
if [ $1 -eq 0 ]; then | |
message="build passes :sparkles:" | |
else | |
message="build fails :bomb:" | |
fi | |
url="https://api.github.com/repos/$PROJ_ORIGIN/commits/$JANKY_SHA1/comments" | |
auth="Authorization: token $GH_TOKEN" | |
data="{\"body\": \"$message\"}" | |
curl -H "$auth" -d "$data" $url &> /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment