Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/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