Skip to content

Commit

Permalink
Add backlog-set-due-date script
Browse files Browse the repository at this point in the history
This script sets the duedate to 14 days from the script's
execution time for tickets that are not low priority and
have not been assigned to anyone

Add dry_run mode. It uses a test json file as first parameter
to perform the tests and thus have predictable results
  • Loading branch information
ilausuch committed Nov 25, 2020
1 parent 9ee43ba commit 043e2d0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions backlog-set-due-date
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh -e

dry_run="${dry_run:-"0"}"
project_id="${project_id:-18}"
ticket_limit="${ticket_limit:-200}"
host="${host:-"https://progress.opensuse.org"}"
issues=$(mktemp)
jquery='.issues | .[] | select(.priority.name!="Low" and .due_date==null and .assignee!=null and .status.name!="Blocked")'

[ "$dry_run" = "1" ] && prefix="echo"

if [ "$dry_run" != "1" ]; then
redmine_api_key="${redmine_api_key:?"Need redmine API key"}"

curl -s -H "X-Redmine-API-Key: $redmine_api_key" "$host/issues.json?project_id=$project_id&limit=$ticket_limit" | jq -r "$jquery" >"$issues"
else
if [ $# -ne 1 ] || [ ! -f "$1" ]; then
echo "Usage: dry_run=1 $1 <test_issues_json_file>"
exit 2
fi

jq -r "$jquery" "$1" >"$issues"
fi

for id in $(jq .id "$issues"); do
due_date=$(date -d"+14 days" +%Y-%m-%d)
$prefix curl -v -H "X-Redmine-API-Key: $redmine_api_key" -H 'Content-Type: application/json' -X PUT \
-d "{\"issue\": {\"due_date\": \"$due_date\", \"notes\": \"Setting due date based on mean cycle time of SUSE QE Tools\"}}" \
"$host/issues/$id.json"
done

0 comments on commit 043e2d0

Please sign in to comment.