DEV Community

mafflerbach
mafflerbach

Posted on

Jira as cli - At least Jira less annoying

Jira... I hate Jira. I hate it so much, that I try to avoid it as much as possible. I think, most of the developers feel with me.
Luckily there is a awesome project which transfer the jira api to a CLI tool which make it, at least less annoying. This tool is go-jira. It is programmed in go-lang and after you fiddled the authentication you are more or less free from using the GUI.

For the common tasks in Jira, I created some zsh function as alias and combined this with a custom configuration which contains the search and filter terms to display my tickets and stories of interests.

# open vim for commenting on a ticket id
alias comment='f() { jira comment $1 };f' 
# assign and unassign ticket 
alias subtaskUnassign='f() { jira unassign $1 };f' 
alias subtaskAssign='f() { jira assign $1 ###MY_LDAPID###  };f' 

# change the workflow status of a subtask or story 
alias subtaskReview='f() { jira transition "In Review" $1 };f' 
alias subtaskProgress='f() { jira transition "In Progress" $1 };f' 
alias subtaskDone='f() { jira transition "Done" $1 };f' 

# custom search for all stories in the current sprint
alias sprint='jira listStories' 

# list Subtask for a story
alias subtask='f() { jira listSubtasks $1};f' 

alias subtaskView='f() { jira view $1};f' 

Enter fullscreen mode Exit fullscreen mode

My config file for the custom search is here

If you want, you can crate a template for special views. I created a template in table format which displayed only the minimum information of a ticket:

{{/*  table template */ -}} 
{{$w := sub termWidth 170 -}}
| {{ "Issue" | printf "%-10s" }}  | {{ "Summary" | printf (printf "%%-%ds" (sub $w 9)) }}  | {{"Status" | printf "%-12s"}} | {{ "Assignee" | printf "%-12s" }} |
{{ range .issues -}} 
| {{ .key | printf "%-10s"}}  | {{ .fields.summary | abbrev (sub $w 9) | printf (printf "%%-%ds" (sub $w 9)) }}  | {{ .fields.status.name | printf "%-12s" }} | {{if .fields.assignee}} {{.fields.assignee.name | printf "%-10s"  }} {{else}}<unassigned>{{end}} |
{{ end -}}
Enter fullscreen mode Exit fullscreen mode

That looks like this:

| Issue   | Summary   | Status    | Assignee     |
| ID-5018 | Summary 1 | Cancelled | <unassigned> |
| ID-4981 | Summary 2 | In Review | user 1       |
| ID-4915 | Summary 3 | Done      | user 1       |
| ID-4914 | Summary 4 | Backlog   | <unassigned> |
Enter fullscreen mode Exit fullscreen mode

The template engine is Hugo which is basically yet another template engine based on curly brackets with dot notation for accessing json objects and quite powerful.

To get a round trip in Vim, I have some mapping as well.

" list all Stories in the current sprint 
 map <leader>jS :call ViewSprint() <CR>
 " Shoes the subtask of a ticket
 map <leader>js :call SubtaskJira(expand("<cWORD>"))<CR>

" shows the ticket Content  
 map <leader>jv :call ViewJira(expand("<cWORD>"))<CR>
" comment on a ticket 
 map <leader>jco :call CommentJira(expand("<cWORD>"))<CR>
 " edit a ticket 
 map <leader>je :call EditJira(expand("<cWORD>"))<CR>

" assign and unassign the tickt from me  
 map <leader>ju :call JiraUnassign(expand("<cWORD>"))<CR>
 map <leader>ja :call JiraAssign(expand("<cWORD>"))<CR>

 " List all Tickets in review in current sprint
 map <leader>jro :call JiraOpenReview()<CR>
 " change the ticket status
 map <leader>jr :call JiraReview(expand("<cWORD>"))<CR>
 map <leader>jd :call JiraDone(expand("<cWORD>"))<CR>
 map <leader>jp :call JiraProgress(expand("<cWORD>"))<CR>
 map <leader>jt :call JiraTodo(expand("<cWORD>"))<CR>

 " list the subtask from my a ticket g:ActualTicket is a global vim variable and is set to a Story id
 map <leader>jl :call SubtaskJira(g:ActualTicket)<CR>
 " Create a subtask for ticket id  under the cursor
 map <leader>jn :call JiraCreateSubtask(expand("<cWORD>"))<CR>

 "shows  specifiv tickets from a different board
 map <leader>jpl :call JiraPlatform()<CR>
 " Open the ticket under the curser in browser
 map <leader>jo :call JiraOpen("<cWORD>")<CR>

Enter fullscreen mode Exit fullscreen mode

The vim functions are implemented here
The implementation is quite naive, but for me its good enough.

And now I just have to find something for Confluence, the another developers nightmare.

Top comments (2)

Collapse
 
offirmo profile image
Offirmo • Edited

Hi mate, I plan to blog about Jira because it seems a lot of developers are "hating" it. Would you mind sharing your concerns? Please comment on this draft: dev.to/offirmo/placeholder-how-to-...

Collapse
 
mikaoelitiana profile image
Mika Andrianarijaona • Edited

And now I just have to find something for Confluence, the another developers nightmare.

So true