-
-
Save devdrops/bcfa0a56af0008c22efa740fcdc646fb to your computer and use it in GitHub Desktop.
make Bamboo support Github Pull Request with Status API
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 | |
GITHUB_API=https://api.github.com | |
# if github enterprise https://your.github.domain/api/v3 | |
if [[ -n ${bamboo_pull_num} ]]; then | |
echo "== send pending status ==" | |
curl -H "Authorization: token $bamboo_GITHUB_STATUS_API_password" --request POST -k --data "{\"state\": \"pending\", \"description\": \"building...\", \"target_url\": \"$bamboo_resultsUrl\"}" https://$GITHUB_API/repos/the-money/condor/statuses/$bamboo_pull_sha > /dev/null | |
echo "git fetch PR $bamboo_pull_num ==" | |
git fetch ${bamboo.repository.git.repositoryUrl} +refs/pull/$bamboo_pull_num/merge: | |
git checkout FETCH_HEAD | |
fi |
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 | |
STATUS=$? | |
if [[ -n ${bamboo_pull_sha} ]]; then | |
if [ $STATUS != 0 ]; then | |
echo 'pull reqeust build failed' | |
curl -k -H "Authorization: token $bamboo_GITHUB_STATUS_API_password" --request POST --data "{\"state\": \"failure\", \"description\": \"failure:(\", \"target_url\": \"${bamboo.buildResultsUrl}\"}" $GITHUB_API/repos/:user/:repo/statuses/$bamboo_pull_sha > /dev/null | |
else | |
echo 'pull request build success' | |
curl -k -H "Authorization: token $bamboo_GITHUB_STATUS_API_password" --request POST --data "{\"state\": \"success\", \"description\": \"Success:)\", \"target_url\": \"${bamboo.buildResultsUrl}\"}" $GITHUB_API/repos/:user/:repo/statuses/$bamboo_pull_sha > /dev/null | |
fi | |
fi |
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 | |
if [[ -n ${bamboo_pull_num} ]]; then | |
echo 'stoping bamboo' | |
curl "http://${bamboo_BAMBOO_USER}:${bamboo_BAMBOO_password}@your.bamboo.domain/build/admin/stopPlan.action?${bamboo.planResultKey}-${bamboo.buildNumber}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment