-
-
Save zavke/5453c1c2148cfacf4ccc1bec98afbbcf to your computer and use it in GitHub Desktop.
JSON export of all Redmine issues with history and related attachments that you have access to using Redmine API
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 | |
# Please install jq, wget and curl for this to work | |
REDMINE_URL="http://www.redmine.org/" # Your redmine URL | |
REDMINE_USER="" # Redmine username | |
REDMINE_PASS="" # Redmine pass | |
offset=0 | |
limit=100 | |
total_count=$(($offset+$limit+1)) | |
while : ; do | |
echo "Getting $limit tickets (skipping first $offset)..." | |
tickets=$(curl --silent --basic --user $REDMINE_USER:$REDMINE_PASS "$REDMINE_URL/issues.json?status_id=*&offset=$offset&limit=$limit") | |
total_count=$(echo $tickets | jq '.["total_count"]') | |
limit=$(echo $tickets | jq '.["limit"]') | |
echo "Got $(echo $tickets | jq '.["issues"] | length') issues out of $total_count." | |
IFS=$'\n' | |
for issue in $(echo $tickets | jq -r '.issues[] | "\(.id);\(.project.name)"'); do | |
project_name=$(echo $issue | awk '{split($0,a,";"); print a[2]}') | |
issue_id=$(echo $issue | awk '{split($0,a,";"); print a[1]}') | |
issue_filename="issues/$project_name/$issue_id.json" | |
echo "Getting issue #$issue_id..." | |
mkdir -p "issues/$project_name" | |
curl --silent --basic --user $REDMINE_USER:$REDMINE_PASS "$REDMINE_URL/issues/$issue_id.json?include=children,attachments,relations,changesets,journals,watchers" -o "$issue_filename" | |
for attachment in $(cat $issue_filename | jq -r .issue.attachments[].content_url); do | |
echo "Saving attachment for issue #$issue_id" | |
wget --auth-no-challenge --http-user=$REDMINE_USER --http-password=$REDMINE_PASS -x -nH -q "$attachment" | |
done | |
done | |
offset=$((offset+limit)) | |
[ $total_count -ge $((offset)) ] || break | |
done | |
echo "Getting issue status list..." | |
curl --silent --basic --user $REDMINE_USER:$REDMINE_PASS "$REDMINE_URL/issue_statuses.json" -o "issue_statuses.json" |
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
published: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment