Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/build_qa_image')
-rwxr-xr-xscripts/build_qa_image53
1 files changed, 51 insertions, 2 deletions
diff --git a/scripts/build_qa_image b/scripts/build_qa_image
index c0001181a51..9c401718336 100755
--- a/scripts/build_qa_image
+++ b/scripts/build_qa_image
@@ -1,11 +1,31 @@
#!/bin/bash
-QA_IMAGE_NAME="gitlab-ee-qa"
-QA_BUILD_TARGET="ee"
+function is_latest_stable_tag() {
+ [ "$(latest_stable_tag)" == "${CI_COMMIT_TAG}" ]
+}
+
+function is_latest_tag() {
+ [ "$(latest_tag)" == "${CI_COMMIT_TAG}" ]
+}
+
+function latest_tag() {
+ git -c versionsort.prereleaseSuffix=rc tag --sort=-v:refname | head -1
+}
+
+function latest_stable_tag() {
+ git -c versionsort.prereleaseSuffix=rc tag --sort=-v:refname | awk '!/rc/' | head -1
+}
if [[ "${CI_PROJECT_NAME}" == "gitlabhq" || "${CI_PROJECT_NAME}" == "gitlab-foss" || "${FOSS_ONLY}" == "1" ]]; then
QA_IMAGE_NAME="gitlab-ce-qa"
QA_BUILD_TARGET="foss"
+# Build QA Image for JH project
+elif [[ "${CI_PROJECT_PATH}" =~ ^gitlab-(jh|cn)\/.*$ || "${CI_PROJECT_NAME}" =~ ^gitlab-jh ]]; then
+ QA_IMAGE_NAME="gitlab-jh-qa"
+ QA_BUILD_TARGET="jhqa"
+else
+ QA_IMAGE_NAME="gitlab-ee-qa"
+ QA_BUILD_TARGET="ee"
fi
# Tag with commit SHA by default
@@ -28,8 +48,37 @@ if [ "${QA_IMAGE_NAME}" == "gitlab-ee-qa" ]; then
DESTINATIONS="${DESTINATIONS} --tag $QA_IMAGE_FOR_AUTO_DEPLOY"
fi
+# On tag pipelines in Canonical projects (gitlab and gitlab-foss), release to
+# Dockerhub also
+if [ -n "${CI_COMMIT_TAG}" ] && [ "${CI_PROJECT_NAMESPACE}" == "gitlab-org" ]; then
+ # Temporarily control release to Dockerhub, until we confirm it works in a
+ # release and finally drops the release job from omnibus-gitlab pipeline.
+ if [ "${RELEASE_QA_IMAGE_TO_DOCKERHUB}" == "true" ]; then
+ echo "$DOCKERHUB_PASSWORD" | docker login "docker.io" -u "$DOCKERHUB_USERNAME" --password-stdin
+
+ DOCKERHUB_TAG_IMAGE="gitlab/${QA_IMAGE_NAME}:${IMAGE_TAG}"
+ DESTINATIONS="${DESTINATIONS} --tag ${DOCKERHUB_TAG_IMAGE}"
+
+ # If we are on latest tag (RC or stable), tag the image as RC
+ if is_latest_tag; then
+ DESTINATIONS="${DESTINATIONS} --tag gitlab/${QA_IMAGE_NAME}:rc"
+ fi
+
+ # If we are on latest stable tag, tag the image as latest
+ if is_latest_stable_tag; then
+ DESTINATIONS="${DESTINATIONS} --tag gitlab/${QA_IMAGE_NAME}:latest"
+ fi
+ else
+ echo "RELEASE_QA_IMAGE_TO_DOCKERHUB not set to true. Not releasing to Dockerhub."
+ fi
+fi
+
echo "Building QA image for '${QA_BUILD_TARGET}' for destinations: ${DESTINATIONS}"
+if [ "${QA_IMAGE_BUILD_DRY_RUN}" == "true" ]; then
+ exit 0
+fi
+
docker buildx build \
--cache-to=type=inline \
--cache-from="$QA_IMAGE_BRANCH" \