jira-cli: a lightweight bash script for easily querying JIRA


Get jira-cli at

https://github.com/MarianoGappa/jira-cli

Why?

JIRA is cool. But it’s slow! And it’s not composable. And devs/ops love the terminal.

Use cases

  • Once I had this requirement to tell some business person about what tickets (JIRA issues) we deployed. We had the ticket numbers on the commit messages, so a git diff ... | grep ... | sort | uniq between deploy tags was kind of enough to get them…only the guy wanted the ticket titles as well. With some clever Sublime multi-cursor hacking plus a terminal I would open all the tickets on Chrome and then copy-paste the titles from them one-by-one. So boring and slow!

  • Then there’s looking for tickets. It’s easy enough on JIRA, with JQL and the UI tools. But it’s slow!

  • Then there’s keeping a personal backlog on JIRA, which can also be achieved with JQL + bookmarks. That process is just fine as it is just using the UI, until you want to combine it with something (i.e. until you want to “pipe it to something”). For example, boss comes in: “can you do this?”. You: “I have these 3 tickets already. What’s the priority?”. What’s the fastest easiest way to get those 3 links so that your boss can prioritise? Or is it better to get ticket names and titles rather than links?

  • Say you have a list of say 5 tickets you’re trying to finish by the end of the week. All you care about is those 5 tickets and their status; why should you load all that clunky UI, set up labels beforehand, etc, etc?

Quick start

Please follow the instructions in the readme.

Note that jira-cli requires the awesome jq tool, which if you don’t have installed, you really should! jira-cli will remind you to install it if it doesn’t find it.

When you first run jira, it’ll open ~/.jiraconfig on your default editor:

Running jira-cli for the first time

After you configure your credentials you should be good to go. Try jira ok one last time to double-check:

~ $ jira ok
OK

Tweaking and examples

Personally, I like to go all the way with the tools I use the most, so I like these aliases:

alias g='git'
alias s='subl .'
alias d='docker'
alias k='kubectl'
alias j='jira'

So if one morning I feel energetic enough to finish up all my backlog, I open all my assigned tickets in Chrome in one go!

~ $ j me | j o

Which translates to:

jira “output all ticket numbers assigned to me” jira “open all tickets from STDIN on browser”)

(To clarify: you don’t have to be so hacker: jira me | jira open works just as well. For more info just type: jira.)

If the boss asks me to do something (like in the example use case), I can give him my backlog for him to prioritise with:

~ $ j me | j t
ABC-123     Do some work
DEF-456     Do some more work
GHI-789     Do very urgent work

When I can’t remember what I was working on, I really like the search command. It shows up to 15 results ordered by last updated using JQL’s text filter, all bound to the projects you configured on ~/.jiraconfig. You can then choose to open one by adding e.g. | j o 3:

~ $ j s cat
JKL-012     Feed the cat
MNO-345     Buy a new cat
PQR-678     Take the cat shopping

~ $ j s cat | j o 3

In closing

Try it, it’s free and open source! It’s not the new grep, but it can be pretty useful once or twice a day. It’s been stable enough for me for a few months now. Please contribute with issues, PRs, etc! If you find it useful, let me know!