Tag Archives: github

Creating issues using github api if travis build is failed.

Hello People,

If you are trying to build some project in travis ci and if it is failed then you have to go to travis ci and login to website and search for the repository where you will trying to see last build failure information, so it a time taking process to search for the log.

Instead of doing long process, i have create a shell script which will execute when build is failed in travis ci and will communicate to github api to create issue and adds build failure link as below.


Please find the link below for createissue shell scripting code.

body="{ \"title\": \"Travis Build no. $TRAVIS_JOB_NUMBER failure \", \"body\": \"Error code: $TRAVIS_TEST_RESULT \n\n JOB URL : $TRAVIS_JOB_WEB_URL\", \"labels\": [\"critical\"]}"
curl -i \
-H "Authorization: token $TicketApi" \
-d "$body" \

view raw


hosted with ❤ by GitHub

and add below code in .travis.yml file to create issue on build failure.

- wget -O createIssue.sh https://gist.githubusercontent.com/hemanth22/3b5d1dae822e95b3b7b30912e7b54a62/raw/fd6405f5e9b9804a468ca96e9178cf1d354ff71c/createIssue.sh
- chmod 777 createIssue.sh
- ./createIssue.sh

This will create a issue on build failure and will help you in tracking in which issue you have fixed the build.

and add TicketApi environment variable in travis ci settings with github OAuth key.



If you like this blog you can say thank you by clicking below say thanks icon and even you can share comments also.