Skip to content

CI: Fix tag used when targeting stable branch

Mitchell Nielsen requested to merge ci-consider-stable-branch-target into master

What does this MR do?

CI: Fix tag used when targeting stable branch

Fixes the image tag used when a branch is targeting a stable
branch. Otherwise, pipelines against a stable branch use the value
from `global.gitlabVersion`, which may not have yet been released
(synced to .com).

Related to !3045 (comment 1322896301)

Testing

#!/bin/bash
# Use the gitlab version from the environment or use stable images when on the stable branch

gitlab_app_version=$(grep 'appVersion:' Chart.yaml | awk '{ print $2}')

# Override: set an example target branch name
# Desired output: 15-10-stable
CI_MERGE_REQUEST_TARGET_BRANCH_NAME='6-10-stable'

if [[ -n "${GITLAB_VERSION}" ]]; then
  image_branch=$GITLAB_VERSION
elif [[ "${CI_COMMIT_BRANCH}" =~ -stable$ ]] && [[ "${gitlab_app_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
  image_branch=$(echo "${gitlab_app_version%.*}-stable" | tr '.' '-')
elif [[ "${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" =~ -stable$ ]]; then
  stable_gitlab_app_version=$(git show "${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}":Chart.yaml | grep 'appVersion:' | awk '{print $2}')
  image_branch=$(echo "${stable_gitlab_app_version%.*}-stable" | tr '.' '-')
fi

echo "Image branch: $image_branch"
$ ./test.sh
15-10-stable

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion.

Required

  • Merge Request Title and Description are up to date, accurate, and descriptive
  • MR targeting the appropriate branch
  • MR has a green pipeline on GitLab.com
  • When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes
  • Documentation created/updated
  • Tests added
  • Integration tests added to GitLab QA
  • Equivalent MR/issue for omnibus-gitlab opened
  • Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file.
Edited by Mitchell Nielsen

Merge request reports