From 241ac1459e6a7aba745717481e9909264543e092 Mon Sep 17 00:00:00 2001 From: conantran Date: Mon, 27 May 2019 11:13:47 +1000 Subject: [PATCH] [SDPSUP-336] Added JIRA credential environment variables and dynamic prefix. (#368) --- .lagoon.yml | 2 +- scripts/jira-post-comment.sh | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.lagoon.yml b/.lagoon.yml index 9b18932a0..222ad5d1f 100644 --- a/.lagoon.yml +++ b/.lagoon.yml @@ -6,7 +6,7 @@ tasks: name: Post deployed URL to JIRA command: | if [[ "$LAGOON_PR_HEAD_BRANCH" != "production" ]]; then - . scripts/jira-post-comment.sh $JIRA_ENDPOINT $JIRA_USERNAME $JIRA_PASSWORD $LAGOON_GIT_BRANCH sdpa $LAGOON_GIT_BRANCH "$LAGOON_PR_TITLE" + . scripts/jira-post-comment.sh $JIRA_ENDPOINT $JIRA_USERNAME $JIRA_PASSWORD $LAGOON_GIT_BRANCH $LAGOON_GIT_BRANCH "$LAGOON_PR_TITLE" fi service: storybook diff --git a/scripts/jira-post-comment.sh b/scripts/jira-post-comment.sh index 6dee698ef..169652835 100644 --- a/scripts/jira-post-comment.sh +++ b/scripts/jira-post-comment.sh @@ -7,14 +7,13 @@ JIRA_URL=$1 USER=$2 PASSWORD=$3 BRANCH=$4 -PREFIX=$5 -PR=$6 -PR_TITLE=$7 +PR=$5 +PR_TITLE=$6 extract_issue() { - local prefix=$1 - local branch=$(echo $2 | tr '[:upper:]' '[:lower:]') - local title=$(echo $3 | tr '[:upper:]' '[:lower:]') + local prefix=$(echo $branch|sed -n "s/feature\/\([a-zA-Z]\{1,\}\).*/\1/p") + local branch=$(echo $1 | tr '[:upper:]' '[:lower:]') + local title=$(echo $2 | tr '[:upper:]' '[:lower:]') # Extracting from branch. local issue=$(echo $branch|sed -n "s/feature\/\($prefix-[0-9]\{1,\}\).*/\1/p") if [ "$issue" == "" ]; then @@ -32,10 +31,10 @@ generate_data() { EOF } -ISSUE=$(extract_issue $PREFIX "$BRANCH" "$PR_TITLE") +ISSUE=$(extract_issue "$BRANCH" "$PR_TITLE") [ "$ISSUE" == "" ] && echo "Branch does not contain issue number" && exit 0 -COMMENT="Deployed to https://storybook-ripple-$PR.lagoon.vicsdp.amazee.io " +COMMENT="Deployed to https://storybook-ripple-$PR.lagoon.vicsdp.amazee.io" echo "Posting comment \"$COMMENT\" for issue \"$ISSUE\""