-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjira
executable file
·44 lines (37 loc) · 1.27 KB
/
jira
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
## Bash script to open up a specific Jira ticket, provided
## as a parameter to this script, in a web browser.
##
## Yes I am lazy.
############################################################
## BEGIN SCRIPT ##
##################
## Check for provided parameter (and uppercase it):
PARAMETER=`echo "$1" | tr a-z A-Z`
# Parse user-provided parameter and determine what to do:
if [ -z $PARAMETER ]; then
echo -e "\nERROR: No parameter provided. You must provide the JIRA
ticket"
echo -e " to work on."
echo -e " Exiting ...\n"
exit;
elif [ ! -z $2 ]; then
echo -e "\nERROR: Too many parameters provided. You must provide only
one"
echo -e " JIRA ticket to work on."
echo -e " Exiting ...\n"
exit;
elif [ `echo $PARAMETER | egrep -c '^[A-Z]{2,9}-[0-9]{1,9}$'` -lt 1 ];
then
echo -e "\nERROR: Invalid JIRA ticket format provided."
echo -e " Expecting something like DOCS-1234"
echo -e " Exiting ...\n"
exit;
else
JIRA=$PARAMETER
fi
JIRA_URL="https://viam.atlassian.net/browse/$JIRA"
# MACOS ONLY: Open $JIRA_URL in web browser:
open $JIRA_URL
# LINUX ONLY: Open $JIRA_URL in web browser (tries everything):
#xdg-open $JIRA_URL || sensible-browser $JIRA_URL || x-www-browser $JIRA_URL || gnome-open $JIRA_URL