+
+ echo "${FUNCNAME[0]}(): INFO: Creating $python venv at $lf_venv"
+
+ case $python in
+ python2*)
+ local pkg_list="$*"
+ # For Python2, just create venv and install pip
+ virtualenv -p "$python" "$lf_venv" || return 1
+ "$lf_venv/bin/pip" install --upgrade --quiet pip || return 1
+ if [[ -z $pkg_list ]]; then
+ echo "${FUNCNAME[0]}(): WARNING: No packages to install"
+ return 0
+ fi
+ echo "${FUNCNAME[0]}(): INFO: Installing: $pkg_list"
+ # $pkg_list is expected to be unquoted
+ # shellcheck disable=SC2086
+ "$lf_venv/bin/pip" install --upgrade --quiet $pkg_list || return 1
+ ;;
+ python3*)
+ local pkg_list=""
+ # Add version specifier for some packages
+ for arg in "$@"; do
+ case $arg in
+ jenkins-job-builder) pkg_list+="jenkins-job-builder==${JJB_VERSION:-2.8.0} " ;;
+ *) pkg_list+="$arg " ;;
+ esac
+ done
+ $python -m venv "$install_args" "$lf_venv" || return 1
+ "$lf_venv/bin/pip" install --upgrade --quiet pip virtualenv || return 1
+ if [[ -z $pkg_list ]]; then
+ echo "${FUNCNAME[0]}(): WARNING: No packages to install"
+ return 0
+ fi
+ echo "${FUNCNAME[0]}(): INFO: Installing: $pkg_list"
+ # $pkg_list is expected to be unquoted
+ # shellcheck disable=SC2086
+ "$lf_venv/bin/pip" install --upgrade --quiet --upgrade-strategy eager \
+ $pkg_list || return 1
+ ;;
+ *)
+ lf-echo-stderr "${FUNCNAME[0]}(): ERROR: No support for: $python"
+ return 1
+ ;;
+ esac
+ if $set_path; then
+ echo "${FUNCNAME[0]}(): INFO: Adding $lf_venv/bin to PATH"
+ PATH=$lf_venv/bin:$PATH
+ return 0
+ else
+ echo "${FUNCNAME[0]}(): INFO: Path not set, lf_venv set to: $lf_venv"
+ fi
+
+} # End lf-activate-venv()
+
+################################################################################
+#
+# NAME
+# lf-git-validate-jira-urls
+#
+# SYNOPSIS
+# # shellcheck disable=SC1090
+# source ~/lf-env.sh
+#
+# lf-git-validate-jira-urls
+#
+# DESCRIPTION
+# Check for JIRA URLS in the commit message
+#
+# RETURN VALUES
+# OK: 0
+# Fail: 1
+#
+################################################################################
+
+function lf-git-validate-jira-urls()
+{
+ echo "Checking for JIRA URLs in commit message..."
+ # if JIRA_URL is not defined, nothing to do
+ if [[ -v JIRA_URL ]]; then
+ 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 [[ -n $jira_link ]]; then
+ lf-echo-stderr "${FUNCNAME[0]}(): ERROR: JIRA URL found in commit message"
+ lf-echo-stderr 'Add jira references as: Issue: <JIRAKEY>-<ISSUE#>, instead of URLs'
+ return 1
+ fi
+ else
+ echo "${FUNCNAME[0]}(): WARNING: JIRA_URL not set, continuing anyway"
+ fi
+ return 0