Last active
October 22, 2024 17:46
-
-
Save marcolussetti/c94d98c15f53710b5e283f0a817175f8 to your computer and use it in GitHub Desktop.
Create issues in Jira with bash from a Json file
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 | |
# Read through this first please | |
# First set some variables | |
echo "Enter username:" | |
read username | |
echo "Enter password:" | |
read -s password | |
echo "Jira url including trailing slash: (e.g. https://jira.company.net/)" | |
read jira_url | |
api_url="${jira_url}rest/api/2/issue/" | |
# Loop through each task in tasks.json | |
task_count=$(jq '.tasks | length' tasks.json) | |
for (( c=0; c<task_count; c++ )) | |
do | |
data=$(jq ".tasks | .[${c}]" tasks.json) | |
echo "Sending task $((c+1))..." | |
curl -D- -u "$username":"$password" --data "$data" -H "Content-Type: application/json" "${api_url}" | |
echo # Print a newline for readability | |
done |
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 | |
# change c to control the number | |
# Read through this first please | |
# First set some variables | |
echo "Enter username:" | |
read username | |
echo "Enter password:" | |
read -s password | |
echo "Jira url including trailing slash: (e.g. https://jira.company.net/)" | |
read jira_url | |
api_url="${jira_url}rest/api/2/issue/" | |
# Just repeat this line each time instead of redoing above | |
c=1 && data=$(jq ".tasks | .[${c}]" tasks.json) && curl -D- -u "$username":"$password" --data "$data" -H "Content-Type: application/json" "${api_url}" |
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
{ | |
"tasks": [ | |
{ | |
"fields": { | |
"summary": "Task Summary 1", | |
"timetracking": { | |
"originalEstimate": "1h", | |
"remainingEstimate": "1h" | |
}, | |
"duedate": "2024-10-18T16:00:00.000-0700", | |
"assignee": { "name": "username1" }, | |
"project": { "key": "PROJECT1"}, | |
"description": "Task Description 1", | |
"customfield_10202": { "name": "requestor_username" }, # Requestor, find your own custom field # and remove this comment | |
"issuetype": { "name": "Task" }, | |
"customfield_10100": 813, # Sprint, find your own custom field # and remove this comment | |
"customfield_10101": "PROJ2-32" # Epic link, find your own custom field # and remove this comment | |
} | |
}, | |
{ | |
"fields": { | |
"summary": "Task Summary 2", | |
"timetracking": { | |
"originalEstimate": "1h", | |
"remainingEstimate": "1h" | |
}, | |
"duedate": "2024-10-18T16:00:00.000-0700", | |
"assignee": { "name": "username2" }, | |
"project": { "key": "PROJECT1"}, | |
"description": "Task Description 2", | |
"customfield_10202": { "name": "requestor_username" }, # Requestor, find your own custom field # and remove this comment | |
"issuetype": { "name": "Task" }, | |
"customfield_10100": 813, # Sprint, find your own custom field # and remove this comment | |
"customfield_10101": "PROJ2-32" # Epic link, find your own custom field # and remove this comment | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment