From: Jessica Wagantall Date: Tue, 11 Jul 2017 20:40:36 +0000 (-0700) Subject: Check for JIRA URLs on JIRA based projects X-Git-Tag: v0.5.0~5 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=793877e39aa8eaec84e29596ad68f20da5c0dae1;p=releng%2Fglobal-jjb.git Check for JIRA URLs on JIRA based projects Check if the project has a JIRA_URL defined in Jenkins and, if so, check if there are JIRA URLS in the commit text. Ignore checks for projects that don't use JIRA Change-Id: I2267aa98e1b6a9c727fb9a54426aef5c5a7131e6 Signed-off-by: Jessica Wagantall --- diff --git a/shell/git-validate-jira-urls.sh b/shell/git-validate-jira-urls.sh index 51d5132a..e542c450 100644 --- a/shell/git-validate-jira-urls.sh +++ b/shell/git-validate-jira-urls.sh @@ -12,13 +12,19 @@ # This script will make sure that there are no JIRA URLs in the commit # message. JIRA URLs will break the its-jira plugin +# Ensure we fail the job if any steps fail. +# Do not treat undefined variables as errors as in this case we are allowed +# to have JIRA_URL undefined set -e -o pipefail set +u -JIRA_LINK=$(git rev-list --format=%B --max-count=1 HEAD | grep -io 'http[s]*://jira\..*' || true) -if [[ ! -z "$JIRA_LINK" ]] +if [ -n "${JIRA_URL}" ]; then - echo 'Remove JIRA URLs from commit message' - echo 'Add jira references as: Issue: -, instead of URLs' - exit 1 + JIRA_LINK=$(git rev-list --format=%B --max-count=1 HEAD | grep -io 'http[s]*://jira\..*' || true) + if [[ ! -z "$JIRA_LINK" ]] + then + echo 'Remove JIRA URLs from commit message' + echo 'Add jira references as: Issue: -, instead of URLs' + exit 1 + fi fi