Changelog with GIT and JIRA: Creating JIRA filter URL based on git commits between two revisions with bash

I am working on a library and a jenkins plugin doing this right, but until then, here is a shell script which creates the URL to a JIRA filter containing the tickets mentioned in all commit messages between the two given revisions.

Besides git and the standard command line tools (grep, sed, tr, egrep, sort, uniq) it needs gawk installed on your system.

Unfortunately I didn't manage to get the variables replaces within gawk's gensub function. If you know how, drop me a line. As a workaround I am sure there is a way with temporary files and/or evaluating a string.

This snippets tries to open your browser if there is any URL. Delete the | xargs xdg-open (and the trailing \ the line before) if you don't want this.

Of course, this script assumes you are in a directory under git control. Assuming you have checked out the Jenkins source code, that's how to get the release notes in form of a JIRA filter between their latest two releases:

$ git log --pretty=oneline jenkins-1.616..jenkins-1.617 | egrep '(JENKINS)-[[:digit:]]' | gawk '{print gensub(/.*(JENKINS)-([0-9]{1,5}).*/, "\\1-\\2", "g")}' | sort | uniq | tr '\n' ',' | awk '{print "" $0 ")"}' | sed 's/,)/)/',JENKINS-28654,JENKINS-28704)  

This is the clickable resulting link:,JENKINS-28654,JENKINS-28704)

comments powered by Disqus