go-jira / jira

simple jira command line client in Go
Apache License 2.0
2.68k stars 328 forks source link

True life custom commands samples #230

Open fabien-michel opened 5 years ago

fabien-michel commented 5 years ago

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

coryb commented 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

coryb commented 5 years ago

Here are a few more that I use for my personal projects:

fabien-michel commented 5 years ago

Thanks for sprint-add. May be we can open a wiki page to store some user's contributed custom command sample ?

s4nk commented 5 years ago

A verbose jira view custom command would be nice - showing things like comments and pull requests

fabien-michel commented 5 years ago

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}}
AndresPineros commented 5 years ago

@coryb Thanks for sprint-add. Also, it would be really nice to have the community custom-commands :)

Flare576 commented 4 years ago

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.