Skip to content

Instantly share code, notes, and snippets.

@brookslyrette
Created December 11, 2015 20:04
Show Gist options
  • Select an option

  • Save brookslyrette/500164f10928522af9c2 to your computer and use it in GitHub Desktop.

Select an option

Save brookslyrette/500164f10928522af9c2 to your computer and use it in GitHub Desktop.
#!/bin/bash
if ls **/test-results/*.xml 1> /dev/null 2>&1; then
curl -H "Authorization: token <your_githib_api_token>" --request POST --data '{"state": "success", "context": "travis-ci/build", "description": "Build Passed"}' https://api.github.com/repos/dotsub/vtms/statuses/${TRAVIS_COMMIT} > /dev/null
else
curl -H "Authorization: token <your_githib_api_token>" --request POST --data '{"state": "failure", "context": "travis-ci/build", "description": "Build Failed!"}' https://api.github.com/repos/dotsub/vtms/statuses/${TRAVIS_COMMIT} > /dev/null
fi
##check for test failures.
if (grep 'failure message' **/test-results/*.xml 1> /dev/null 2>&1) then
mainJunit=$(find **/test-results/*.xml -print0 | xargs -0 grep 'failure message' | wc -l)
curl -H "Authorization: token <your_githib_api_token>" --request POST --data '{"state": "failure", "context": "travis-ci/tests", "description": "'"${mainJunit}"' Test(s) failed!"}' https://api.github.com/repos/dotsub/vtms/statuses/${TRAVIS_COMMIT} > /dev/null
else
curl -H "Authorization: token <your_githib_api_token>" --request POST --data '{"state": "success", "context": "travis-ci/tests", "description": "Tests Passed"}' https://api.github.com/repos/dotsub/vtms/statuses/${TRAVIS_COMMIT} > /dev/null
fi
#check for findbugs warnings
if (grep 'BugInstance' **/reports/findbugs/*.xml 1> /dev/null 2>&1) then
mainFb=$(grep -c 'BugInstance' **/reports/findbugs/main.xml)
testFb=$(grep -c 'BugInstance' **/reports/findbugs/test.xml)
sumFB=$(($mainFb+$testFb/2))
curl -H "Authorization: token <your_githib_api_token>" --request POST --data '{"state": "failure", "context": "travis-ci/findbugs", "description": "FindBugs found '"${sumFB}"' issues!"}' https://api.github.com/repos/dotsub/vtms/statuses/${TRAVIS_COMMIT} > /dev/null
else
curl -H "Authorization: token <your_githib_api_token>" --request POST --data '{"state": "success", "context": "travis-ci/findbugs", "description": "FindBugs Passed"}' https://api.github.com/repos/dotsub/vtms/statuses/${TRAVIS_COMMIT} > /dev/null
fi
#check for checkstyle warnings
if (grep 'error' **/reports/checkstyle/*.xml 1> /dev/null 2>&1) then
mainCs=$(grep -c 'error' **/reports/checkstyle/main.xml)
testCs=$(grep -c 'error' **/reports/checkstyle/test.xml)
sumCs=$(($mainCs+$testCs))
curl -H "Authorization: token <your_githib_api_token>" --request POST --data '{"state": "failure", "context": "travis-ci/checkstyle", "description": "Checkstyle found '"${sumCs}"' issues!"}' https://api.github.com/repos/dotsub/vtms/statuses/${TRAVIS_COMMIT} > /dev/null
else
curl -H "Authorization: token <your_githib_api_token>" --request POST --data '{"state": "success", "context": "travis-ci/checkstyle", "description": "Checkstyle Passed"}' https://api.github.com/repos/dotsub/vtms/statuses/${TRAVIS_COMMIT} > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment