Skip to content

Instantly share code, notes, and snippets.

@anshumanbh
Created August 25, 2015 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anshumanbh/5ff9c4d55710c91c82bc to your computer and use it in GitHub Desktop.
Save anshumanbh/5ff9c4d55710c91c82bc to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
unset http_proxy
unset https_proxy
virtualenv env
. env/bin/activate
export JIRA=jira.app.com
echo Authenticating to JIRA
curl -c data/cookies.txt -X POST -d @data/credentials.json -H "Content-Type: application/json" https://$JIRA/rest/auth/1/session
echo Creating an issue
issue=$(curl -b data/cookies.txt -d @data/data.json -H "Content-Type: application/json" -X POST https://$JIRA/rest/api/2/issue | grep -w key | sed 's/.*key":"//' | sed 's/",.*//')
echo Sending the XML and HTML reports as attachments to the JIRA ticket
xmlreport=`ls report*.xml`
htmlreport=`ls report*.html`
curl -b data/cookies.txt -X POST -H "X-Atlassian-Token: nocheck" -F "file=@$xmlreport" https://$JIRA/rest/api/2/issue/$issue/attachments
curl -b data/cookies.txt -X POST -H "X-Atlassian-Token: nocheck" -F "file=@$htmlreport" https://$JIRA/rest/api/2/issue/$issue/attachments
echo Destroying JIRA user session
curl -c data/cookies.txt -X DELETE -H "Content-Type: application/json" https://$JIRA/rest/auth/1/session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment