I’ll probably need this again so writing it up: is an awesome little helper syncing tasks to (where I use to track hours spent). It connects to various ticket systems like , or .

Today I had to tweak it a little though, because I have no idea where to put client certificates for Python’s requests lib and my current customer requires that. Any HTTPS request without will fail with status code 400: No required SSL certificate was sent.

For this I edited ~/.local/lib/python3.11/site-packages/bugwarrior/services/gitlab.py line 364 from this:

response = requests.get(url, headers=headers, verify=self.verify_ssl, **kwargs)

to

response = requests.get(url, cert=('/path/to/client.crt', '/path/to/client.key'), headers=headers, verify=self.verify_ssl, **kwargs)

Important: Any request to _some_ GitLab by Bugwarrior will offer the client cert now. That’s fine for me because I’ve currently only one GitLab system to check at the moment. There may be better ways to achieve this but I’ve seen no obvious in the docs at https://bugwarrior.readthedocs.io/en/latest/services/gitlab.html – YMMV.

This is how I import my deadlines for tickets from our Jira bugtracker to our Zarafa ical gateway (running on localhost only but since I’ve a real account I could easily install a crontab for this for my system user).

Notes:

– The script makes use of phyton as well
– The script makes use of the Jira rest api (needs to be enabled)
– The script makes use of the (free) JIRA Calendar Plugin (https://marketplace.atlassian.com/plugins/com.atlassian.jira.ext.calendar/versions#b20107)
– The script uses a hardcoded filter id 10100. The filter must be created by the Jira user before. In my case it’s simply a filter that returns all projects I’m assigned to.
– The calendar used (e.g. “Jira”) must be manually created by the Zarafa user before and will be overwritten everytime the script runs! (Do not use default calendar)
– Dunno how to check whether ICS file loaded fine so run it manually and check whether new items show up in the calendar 🙂

It can probably easy adapted to other ics servers as well. I run this all 15 minutes during working days making use of crontab.


#!/bin/bash
JIRAUSER="changeme"
JIRAPASS="changeme"
JIRAICS="$HOME/jira.tmp.ics"
JIRAURL="jira.example.com"
#secure folder with e.g. umask 077
JIRACOOKIE="$HOME/.cookies/jira.cookie"
ZARAFAUSER=="changeme@example.com"
ZARAFAPASS=="changeme"
#
#Do NOT use default "Calendar", ICS will OVERWRITE it!
#Create an OWN calendar for Jira entries ONLY!
#
ZARAFACALENDAR="Jira"
if [ -f "$JIRAICS" ]; then
rm "$JIRAICS"
fi
if [ ! -f "$JIRACOOKIE" ]; then
JIRATEST=`/usr/bin/curl -s -u "$JIRAUSER":"$JIRAPASS" --cookie-jar "$JIRACOOKIE" "https://$JIRAURL/rest/api/2/user?username=$JIRAUSER" -s | python -mjson.tool | grep -oP "(?<=\"name\": \")[^\"]+"`
else
JIRATEST=`/usr/bin/curl -s --cookie "$JIRACOOKIE" "https://$JIRAURL/rest/api/2/user?username=$JIRAUSER" -s | python -mjson.tool | grep -oP "(?<=\"name\": \")[^\"]+"`
fi
if [ "$JIRATEST" != "$JIRAUSER" ]; then
echo "Error getting Jira username $JIRAUSER"
rm "$JIRACOOKIE"
exit -1
fi
/usr/bin/curl -s --cookie "$JIRACOOKIE" --output "$JIRAICS" "https://$JIRAURL/plugins/servlet/calendar?searchRequestId=10100&dateFieldName=duedate&showVersions=true" || exit $?
if [ -f "$JIRAICS" ]; then
/usr/bin/curl -s -u "$ZARAFAUSER":"$ZARAFAPASS" -T "$JIRAICS" "http://localhost:8080/ical/$ZARAFAUSER/$ZARAFACALENDAR"
rm "$JIRAICS"
fi