Skip to content

Instantly share code, notes, and snippets.

@aaronzirbes
Created April 6, 2016 15:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronzirbes/c1f34b981c56caa57a496de6191d7518 to your computer and use it in GitHub Desktop.
Save aaronzirbes/c1f34b981c56caa57a496de6191d7518 to your computer and use it in GitHub Desktop.
Jira Script to open JIRA
#!/bin/bash
JIRA_HOST="https://jira.atlassian.com"
ISSUE=""
DEFAULT_PROJECT=PCDR
if [ "$1" == "" ]; then
current_branch=`git rev-parse --abbrev-ref HEAD`
if [ $? == 0 ] && [[ "${current_branch}" =~ [A-Za-z]-[0-9] ]]; then
echo "Using git branch name as JIRA issue"
ISSUE=$current_branch
fi
else
if [[ "${1}" =~ [A-Za-z]-[0-9] ]]; then
ISSUE="${1}"
elif [[ "${1}" =~ ^[0-9]+$ ]]; then
ISSUE="${DEFAULT_PROJECT}-${1}"
fi
fi
if [ "$ISSUE" != "" ]; then
open ${JIRA_HOST}/browse/${ISSUE}
else
echo "Usage:"
echo ""
echo " jira [issue]"
echo ""
echo "Where [issue] is in the form of 'PCDR-1234' or just '1234' and your "
echo "default project prefix will be applied."
echo ""
echo "If no arguments are supplied, but you are in a git repo with a branch that "
echo "matches a story number, then the branch name will be used as the issue identifier."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment