Sharing some Custom Commands
AlJohri opened this issue · comments
Hi all, I wanted to just share some custom commands that I pieced together and found useful since documentation was a little hard to come by. I'm using like 0.1% of what this tool has to offer but its proven useful nonetheless.
-
Create/Edit Jira Ticket using Browser (instead of $EDITOR)
This opens the browser to the CreateIssueDetails page with several fields pre-populated to make it easier to create tickets without forgetting to add a component, epic, etc.
Usages:
jira qc
,jira qc --component1
,jira qc --epic PROJ-1234
,jira qc --component1 --component2 --summary "this is the title"
For epics or sprints, check which custom field ID you're using by running:
jira createmeta | jq '.fields'
. Edit the board name, component id, sprint field name, and epic field name below:- name: quick-create aliases: - qc help: quick create jira ticket using web ui options: - name: type default: 3 - name: priority default: 3 - name: summary default: Title - name: reporter default: $(whoami) - name: component1 type: BOOL default: false - name: component2 type: BOOL default: false - name: epic script: | board_name="!!YOUR BOARD NAME HERE!!" board_id=$({{jira}} req "/rest/agile/1.0/board?projectKeyOrId=$JIRA_PROJECT&name=$board_name" --gjq values.0.id) project_id=$({{jira}} req "/rest/agile/1.0/board/$board_id/project/" --gjq values.0.id) sprint_id=$({{jira}} req "/rest/agile/1.0/board/$board_id/sprint?state=active" --gjq values.0.id) echo "Creaing issue on project $JIRA_PROJECT ($project_id), board $board_name ($board_id), sprint $sprint_id" url="https://issues.labcollab.net/secure/CreateIssueDetails%21init.jspa?" url+="pid=$project_id" url+="&customfield_10227=$sprint_id" url+="&reporter={{options.reporter}}" url+="&issuetype={{options.type}}" url+="&summary={{options.summary}}" url+="&priority={{options.priority}}" if [[ "{{ options.component1 }}" == "true" ]]; then url+="&components=!!COMPONENT1_IDHERE!!" fi if [[ "{{ options.component2 }}" == "true" ]]; then url+="&components=!!COMPONENT2_IDHERE!!" fi if [[ "{{ options.epic }}" != "<no value>" ]]; then url+="&customfield_10600=key:{{ options.epic }}" fi echo "\nURL: $url" open "$url"
Thanks to @coryb for this comment: #230 (comment).
-
Open Named Query using FZF
Opens a named query using FZF to create a text user interface. You can easily search through issues and use your arrow keys or mouse to click on different issues and see them populate in the sidebar on the right.
Requires:
brew install fzf
.- name: ls-named-query-fzf aliases: - lf help: ls with named queries using fzf interface args: - name: query script: | {{jira}} ls -n {{args.query}} | \ fzf --preview="echo {} | cut -d : -f 1 | xargs -I % sh -c 'jira view %'"
Credit goes to @itai-stratoscale from #156 (comment).
-
Auth via Cookies for private Jira.
Run
jira a
to grab Jira cookies from Chrome to authenticate with difficult private Jira's behind SSO.Requires:
brew install jq
andpip3 install --user get-browser-cookies
.- name: auth aliases: - a help: authenticate to jira using cookies script: | get-browser-cookies \ --browser chrome \ --domain !!YOUR_JIRA_DOMAIN_HERE!! | \ jq 'select(.value | contains("\"") | not)' | \ jq '{ "Name": .name, "Value": .value, "Path": .path, "Domain": .domain, "Expires": .expires, "Secure": .secure}' | \ jq -s '.' > ~/.jira.d/cookies.js
Thanks to the folks in #241 for the idea. Looks like the folks in #231 came to a similar approach.