Syncing JIRA work logs with ledger

And yes, you can create work logs with ledger, too!

When doing contract work, it’s important to properly clock your work (which is the act of measuring how much time you spend and on what). This might be important for your own projects, too, if you want to track where time is wasted, for example. At plapadoo, we strive for solutions that involve open, plain-text (electronic) formats. You know, stuff you can put into a git repository and do diffs, blame people, use your Linux tools on, etc.…

If you’re into the aforementioned open, libre evangelism, you might know ledger, which is usually mentioned when talking about plain text accounting and book-keeping. And we’re using ledger for that as well. But really, if you replace “$” or “€” with “hours”, you can do “time-accounting” in ledger, too. In that sense, time is (semantically equivalent to) money. And ledger fulfills the criteria mentioned above: it’s an open plain-text format, and it’s pretty easy to read by humans, too:

2018-04-29 socialmedia  ; Medium article about ledger clocking
NonProgramming:usage:SocialMedia:Medium 2.0h ; :Philipp:
NonProgramming:quota:SocialMedia

However, your customer might use different tools, and might expect different work logs from you. In our case, we have a customer using JIRA. The experience with JIRA has been pretty smooth thus far, and JIRA does have “work logs” attached to tickets as well. However, to keep all our work logs consistent, no matter what the customer expects, we had to double-book into ledger and JIRA. And as you might imagine, we made mistakes synchronizing these two tools by hand — lots of mistakes.

So, being the “dev-ops” we are, we automated! We wrote “ledger-jira-sync”, a tool that takes the following inputs:

  • your ledger work logs
  • a file that links each work log account to a JIRA ticket
  • your JIRA login information (including the JIRA URL)
  • your name (which you have to attach to the ledger accounts by means of a tag)

and does the following¹:

  • determines all the work you clocked into ledger
  • determines all the work you clocked into JIRA
  • deletes every work log item in JIRA not present in ledger
  • adds all work log items to JIRA present in ledger

This way, we constructed a unidirectional ledger → JIRA sync, meaning the ledger file will be the “ground truth”. The program is available for every platform supporting python 3 and ledger. Feel free to experiment and let us know if it works (or doesn’t work) for you.

¹ Don’t worry, the program first tells you what it’ll do and give you the option to cancel.