-
-
Save aaronzirbes/c1f34b981c56caa57a496de6191d7518 to your computer and use it in GitHub Desktop.
Jira Script to open JIRA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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