Last active
September 11, 2023 12:42
-
-
Save Lajule/7d30c553ccfc5204c49068fd65b1d7cb to your computer and use it in GitHub Desktop.
Create Jira tickets from command line
This file contains hidden or 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
#!/bin/bash | |
JIRA_USER='[email protected]:TOKEN' | |
JIRA_PROJECT=PROJET_NAME | |
JIRA_ISSUETYPE=XXXX | |
if (( $# < 1 )); then | |
echo 'Missing arguments' >&2 | |
exit 1 | |
fi | |
rep="$(curl -s \ | |
--request POST \ | |
--url 'https://ringover.atlassian.net/rest/api/3/issue' \ | |
--user "${JIRA_USER}" \ | |
--header 'Accept: application/json' \ | |
--header 'Content-Type: application/json' \ | |
--data "{ | |
\"fields\": { | |
\"summary\": \"$1\", | |
\"issuetype\": { | |
\"id\": \"${JIRA_ISSUETYPE}\" | |
}, | |
\"project\": { | |
\"key\": \"${JIRA_PROJECT}\" | |
}, | |
\"description\": { | |
\"type\": \"doc\", | |
\"version\": 1, | |
\"content\": [ | |
{ | |
\"type\": \"paragraph\", | |
\"content\": [ | |
{ | |
\"text\": \"${2:-"No description"}\", | |
\"type\": \"text\" | |
} | |
] | |
} | |
] | |
} | |
} | |
}" | jq -r '.key')" | |
if [[ "${rep}" = "null" ]]; then | |
echo 'Issue not created' >&2 | |
exit 1 | |
fi | |
printf "https://ringover.atlassian.net/browse/%s\n" "${rep}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment