xmpp.chapril.org-tools/rapport_activite/update_ticket.sh

47 lines
1.1 KiB
Bash
Raw Normal View History

#! /bin/bash
REDMINE_BASE_URL="https://agir.april.org"
TICKET_ID=4047
REPORT_COMMAND="/usr/local/sbin/display_activity_report"
if [ 'z' = "z${API_KEY}" ]; then
echo "Missing environment variable API_KEY" >&2
exit 1
fi
main() {
post_report
}
post_report() {
datafile=$(mktemp /tmp/report_stats_$(date +%Y-%m-%d_%H%M)_XXXX.json)
cat <<EOF > "${datafile}"
{
"issue": {
"notes": "$(${REPORT_COMMAND} | sed -z 's/\n/\\n/g')"
}
}
EOF
curl -s \
-H "Content-Type: application/json" \
-H "X-Redmine-API-Key: ${API_KEY}" \
-X PUT --data-binary "@${datafile}" \
"${REDMINE_BASE_URL}/issues/${TICKET_ID}.json"
rm "${datafile}"
}
# debug function
last_comment_date() {
curl -H "X-Redmine-API-Key: ${API_KEY}" -s "${REDMINE_BASE_URL}/issues/${TICKET_ID}.json?include=journals" \
| jq '.issue.journals | last | .created_on'
}
# debug function
list() {
curl -H "X-Redmine-API-Key: ${API_KEY}" -s "${REDMINE_BASE_URL}/issues/${TICKET_ID}.json?include=journals" \
| jq '.issue.journals[] | [.user.name, .notes]'
}
main