Created
March 10, 2022 21:23
-
-
Save designfrontier/826fd87d3c5594e394ba15ceae5cd134 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
# https://id.atlassian.com/manage-profile/security/api-tokens | |
# for getting your tokens :pointup: | |
GIT_MESSAGE=$(git log -n 1) | |
read -p "Brief Summary:" SUMMARY | |
read -p "Description:" DESCRIPTION | |
echo "" | |
echo 'Please enter ticket type: ' | |
select T in "${JIRA_TICKET_TYPES[@]}" | |
do | |
case $T in | |
"Story") | |
TYPE="Story"; break | |
;; | |
"Bug") | |
TYPE="Bug"; break | |
;; | |
"Task") | |
TYPE="Task"; break | |
;; | |
*) echo "invalid option $REPLY";; | |
esac | |
done | |
echo "" | |
echo 'Please select project: ' | |
select P in "${JIRA_PROJECTS[@]}" | |
do | |
case $P in | |
"SOLFLOW") | |
PROJECT="SOLFLOW"; break | |
;; | |
*) echo "invalid option $REPLY";; | |
esac | |
done | |
read -r -d '' JSON << eof | |
{ | |
"fields":{ | |
"project":{ | |
"key": "$PROJECT" | |
}, | |
"summary": "$SUMMARY", | |
"description": "$DESCRIPTION", | |
"issuetype": { | |
"name": "$TYPE" | |
} | |
} | |
} | |
eof | |
CLEANED_JSON=$(echo "$JSON"|tr '\n' ' ') | |
RES=$(curl -sS -D- \ | |
-u "$JIRA_USERNAME:$JIRA_TOKEN" \ | |
-X POST \ | |
--data "$CLEANED_JSON" \ | |
-H "Content-Type: application/json" \ | |
"$JIRA_BASE_URL/rest/api/2/issue/") | |
KEY=$(echo "${RES##*$'\n'}" | jq .key | tr -d '"') | |
echo "Ticket created: $KEY" | |
open "$JIRA_BASE_URL/browse/$KEY" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment