Skip to content

Instantly share code, notes, and snippets.

@Lajule
Last active September 11, 2023 12:42
Show Gist options
  • Save Lajule/7d30c553ccfc5204c49068fd65b1d7cb to your computer and use it in GitHub Desktop.
Save Lajule/7d30c553ccfc5204c49068fd65b1d7cb to your computer and use it in GitHub Desktop.
Create Jira tickets from command line
#!/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