mumble.chapril.org-tools/rapports_activites/update_redmine_ticket.sh

43 lines
1.1 KiB
Bash
Raw Normal View History

#! /bin/bash
# Lecture configuration
CONFIG="/etc/mumble.chapril.org/mumblechaprilorg.conf"
CONFIG_KEY="/etc/chagirbot/agiraprilorg.conf"
source ${CONFIG}
source ${CONFIG_KEY}
REDMINE_API_KEY=${key}
main() {
post_report
}
post_report() {
datafile=$(mktemp /tmp/report_stats_$(date +%Y-%m-%d_%H%M)_XXXX.json)
cat <<EOF > "${datafile}"
{
"issue": {
"notes": "$(/srv/mumble.chapril.org/tools/rapports_activites/rapport_activites.sh | sed -z 's/\n/\\n/g')"
}
}
EOF
curl -s \
-H "Content-Type: application/json" \
-H "X-Redmine-API-Key: ${REDMINE_API_KEY}" \
-X PUT --data-binary "@${datafile}" \
"${REDMINE_BASE_URL}/issues/${REDMINE_TICKET_ID}.json"
rm "${datafile}"
}
last_comment_date() {
curl -H "X-Redmine-API-Key: ${REDMINE_API_KEY}" -s "${REDMINE_BASE_URL}/issues/${REDMINE_TICKET_ID}.json?include=journals" \
| jq '.issue.journals | last | .created_on'
}
list() {
curl -H "X-Redmine-API-Key: ${REDMINE_API_KEY}" -s "${REDMINE_BASE_URL}/issues/${REDMINE_TICKET_ID}.json?include=journals" \
| jq '.issue.journals[] | [.user.name, .notes]'
}
main