Open fabien-michel opened 5 years ago
There are no collection of sample custom commands now, there are a few examples in the closed issues, here is an example how to set up sprint related commands: https://github.com/Netflix-Skunkworks/go-jira/issues/135#issuecomment-355786732
Here are a few more that I use for my personal projects:
display list of epic issues with usage jira epics
custom-commands:
- name: epics
help: list epics
script: |-
{{jira}} list --template epics --query "resolution = unresolved AND issuetype = Epic AND project = $JIRA_PROJECT ORDER BY Rank Desc" --queryfields=customfield_12551,issuetype,priority,assignee,status,created,reporter
here is a more complex one that tries to figure out the the scrum board id and assign a provided issue to it. There is an option -n
to assign the issue to the "next" sprint (the "future" one) or the currently "active" one. Usage: jira sprint-add ISSUE-123
or jira sprint-add --next ISSUE-123
custom-commands:
- name: sprint-add
help: add issue to active sprint for project
options:
- name: next
short: 'n'
type: bool
help: add issue to next sprint, rather than the active one
args:
- name: ISSUE
required: true
script: |
state={{if options.next}}future{{else}}active{{end}}
board_id=$({{jira}} req "/rest/agile/1.0/board?projectKeyOrId=$JIRA_PROJECT&type=scrum" --gjq values.0.id)
sprint_id=$({{jira}} req "/rest/agile/1.0/board/$board_id/sprint?state=$state" --gjq values.0.id)
if [ "$sprint_id" = "" ]; then
echo "ERROR: No $state sprint" >&2
exit 1
fi
{{jira}} req -M POST "/rest/agile/1.0/sprint/$sprint_id/issue" "{\"issues\":[\"{{args.ISSUE}}\"]}"
Thanks for sprint-add. May be we can open a wiki page to store some user's contributed custom command sample ?
A verbose jira view
custom command would be nice - showing things like comments and pull requests
Here are mine:
Display current sprint with ability to filter by status
custom-commands:
- name: sprint
help: display issues for active sprint
options:
- name: status
short: s
default: ""
script: |-
case "{{options.status}}" in
t|todo) STATUS="to do"
;;
p|progress) STATUS="in progress"
;;
rev|review) STATUS="in review"
;;
r) STATUS="resolved"
;;
d) STATUS="done"
;;
"<no value>") STATUS=""
;;
*) STATUS="{{options.status}}"
esac
if [ -n "$STATUS" ]; then
STATUS_QUERY="and status='$STATUS'"
fi
if [ -n "$JIRA_PROJECT" ]; then
{{jira}} list --template table --query "sprint in openSprints() and resolution = unresolved and project=$JIRA_PROJECT $STATUS_QUERY ORDER BY rank asc, created"
else
echo "\"project: ...\" configuration missing from .jira.d/config.yml"
fi
Put many issues to "in review"
custom-commands:
- name: review
help: Transition issue to In review state
args:
- name: ISSUE
required: true
repeat: true
script: |-
{{range args.ISSUE}}
{{jira}} transition --noedit "resloved to in review" {{.}}
sleep 0.2
{{end}}
@coryb Thanks for sprint-add. Also, it would be really nice to have the community custom-commands :)
This is an older issue, but it's still marked as OPEN and I feel like this might be a meaningful contribution:
https://github.com/Flare576/dotfiles/blob/master/.jira.d/config.yml
I have ~20 custom commands I use on a daily basis.
(What follows is a super-long-winded example of using the most common ones. Feel free to ignore and just look through the config!)
My current project has moved to a hosted Jira instance, so I'm not able to rely on the API token anymore (I miss it a lot). So, every morning I have to load up the website, grab the cookie
from a XHR request, and run
jira cookie 'whatever=stuff; was=in_there'
after that, I pull down the tickets from the current sprint
jira s
and read through them. Our team operates on "devs should grab from the QA column if there's a story there" so I usually pick up the first ticket in QA, say 123
jira w PROJ-123
jira v
which will then spit out the ticket data. If it turns out I can't actually do anything with it, I pop it off and grab the next one
jira w -r
jira w PROJ-124
Once I find a story I can work, say it's still a QA story, I need to mark myself the reviewer (our team has a custom field so we don't step on each-other's toes)
jira qa -r
and then copy the Acceptance Criteria out of the vim
window that opens. I then open the story for review
jira r
and use the provided template to review. After filling out the template and :wq
from vim, go-jira pops open a transition
window for me, defaulted to Sign Off
, optimistically assuming the story passed. If it didn't, I can Ctrl+Z
to background the vim doc and do
jira ts
to see the valid transitions for the story, then fill in that data going back to fg
.
Hi, I'm not very comfortable with custom commands and I am seeking for a bunch of user contributed custom-commands to help me write my owns. The doc seems to be complete, but it would be more instructive to have some real and more complex examples.
There is already a place for this ? Thanks