Validate URLs using Jenkins env variable 36/5536/1
authorJessica Wagantall <jwagantall@linuxfoundation.org>
Fri, 14 Jul 2017 07:02:39 +0000 (00:02 -0700)
committerJessica Wagantall <jwagantall@linuxfoundation.org>
Fri, 14 Jul 2017 07:02:39 +0000 (00:02 -0700)
Since we are adding in Jenkins a variable
JIRA_URL, we want to make the logic of this
script so that it picks up its value to look
for related URLs in the commit text rather
than using a static value.

Change-Id: Id6d1df4cfefa0d37f7f74a48d8d5149379ede3eb
Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org>
shell/git-validate-jira-urls.sh

index e542c45..a505d27 100644 (file)
@@ -20,7 +20,8 @@ set +u
 
 if [ -n "${JIRA_URL}" ];
 then
-  JIRA_LINK=$(git rev-list --format=%B --max-count=1 HEAD | grep -io 'http[s]*://jira\..*' || true)
+  BASE_URL=$(echo $JIRA_URL | awk -F'/' '{print $3}')
+  JIRA_LINK=$(git rev-list --format=%B --max-count=1 HEAD | grep -io "http[s]*://$BASE_URL/" || true)
   if [[ ! -z "$JIRA_LINK" ]]
   then
     echo 'Remove JIRA URLs from commit message'