diff --git a/jenkins/scripts/merge_tags.sh b/jenkins/scripts/merge_tags.sh index bbbafef667..0c9f2485df 100755 --- a/jenkins/scripts/merge_tags.sh +++ b/jenkins/scripts/merge_tags.sh @@ -14,16 +14,16 @@ TAG=$1 -# Avoid acting on any tag which is not strictly an all-numeric/stops string -# since the logic below relies on a simple numeric sort. Ordering of -# non-numeric strings are locale-specific, and situations like PEP-440 violate -# assumptions about non-numeric versions being alpha-sorted anyway. This check -# is redundant since we should never allow a tag containing non-numeric version -# components through the filter for the release pipeline in Zuul, but is here -# as a safeguard to validate that expectation since "Git tags are forever." -if ! echo $TAG|grep '^[0-9\.]*$'; then - echo "ERROR: Triggered on non-release $TAG tag." - exit 1 +# Only merge release tag if it's on a stable branch +if ! $(git branch -r --contains "$TAG" | grep "stable/" >/dev/null); then + echo "Tag $TAG was not pushed to a stable branch, ignoring." + exit 0 +fi + +# Make sure the tag does not correspond to a patch release +if ! echo $TAG|grep '^[0-9]\+\.[0-9]\+\(\.0\|\)$'; then + echo "Triggered on patch release $TAG tag, ignoring." + exit 0 fi git config user.name "OpenStack Proposal Bot" @@ -37,15 +37,9 @@ git reset --hard origin/master MASTER_MINOR=`git describe|cut -d. -f-2` TAG_MINOR=`echo $TAG|cut -d. -f-2` -# If the tag is for a patch version where its minor matches master's, skip -if [ "$MASTER_MINOR" = "$TAG_MINOR" ]; then - echo "Skipping $TAG which shares master's $MASTER_MINOR version." - exit 0 -fi - # If the tag is for an earlier version than master's, skip if [ "$(echo $(echo -e "$MASTER_MINOR\n$TAG_MINOR"|sort -V))" \ - = "$TAG_MINOR $MASTER_MINOR" ]; then + \!= "$MASTER_MINOR $TAG_MINOR" ]; then echo "Skipping $TAG which sorts before master's $MASTER_MINOR version." exit 0 fi