Created
November 27, 2017 07:17
-
-
Save jsyi/bdc31adf11c3ce22e5e18f2fbeda081b to your computer and use it in GitHub Desktop.
Bamboo build task script for updating Github branch status after build/tests are complete.
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 | |
cd ${bamboo.build.working.directory} | |
REPO_URL=${bamboo.planRepository.1.repositoryUrl} | |
[[ $REPO_URL =~ github.com\/(.*).git ]] | |
STATUS_UPDATE_URL="https://api.github.com/repos/${BASH_REMATCH[1]}/statuses/${bamboo.repository.revision.number}" | |
if ls **/test-reports/*.xml 1> /dev/null 2>&1; then | |
curl -H "Authorization: token ${bamboo.githubStatusUpdateTokenForMeshkoreaDev}" --request POST --data '{"state": "success", "context": "bamboo/build", "description": "Bamboo build Completed!", "target_url": "${bamboo.buildResultsUrl}"}' $STATUS_UPDATE_URL > /dev/null | |
else | |
curl -H "Authorization: token ${bamboo.githubStatusUpdateTokenForMeshkoreaDev}" --request POST --data '{"state": "failure", "context": "bamboo/build", "description": "Bamboo build Failed!", "target_url": "${bamboo.buildResultsUrl}"}' $STATUS_UPDATE_URL > /dev/null | |
fi | |
##check for test failures. | |
if (grep '<failure' test-reports/*.xml 1> /dev/null 2>&1) then | |
failures=$(grep '<failure' test-reports/*.xml | wc -l) | |
curl -H "Authorization: token ${bamboo.githubStatusUpdateTokenForMeshkoreaDev}" --request POST --data '{"state": "failure", "context": "bamboo/tests", "description": "'"${failures}"' Test(s) failed!", "target_url": "${bamboo.buildResultsUrl}"}' $STATUS_UPDATE_URL > /dev/null | |
else | |
curl -H "Authorization: token ${bamboo.githubStatusUpdateTokenForMeshkoreaDev}" --request POST --data '{"state": "success", "context": "bamboo/tests", "description": "Tests Passed", "target_url": "${bamboo.buildResultsUrl}"}' $STATUS_UPDATE_URL > /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment