From 3b490768c41410d2271d86b6879d8b9a8b519af5 Mon Sep 17 00:00:00 2001 From: John McDonnell Date: Thu, 7 Dec 2023 14:53:11 +0000 Subject: [PATCH] Allow configuring target repo for rails-specs In some situations we will want to run the rails-specs job against a repository other than the default gitlab-org/gitlab. Examples of this may be against security release. We can allow a default value canbe set, but when the need arises, an ENV can be set to target the job against the relevant repo. Fixes https://gitlab.com/gitlab-org/gitaly/-/issues/5727 --- .gitlab-ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 178c7a3b44..04b8e9f979 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -55,6 +55,8 @@ variables: # users. TEST_UID: 9999 RAILS_BRANCH_FOR_JOB: "gitaly-ci-jobs-$CI_PIPELINE_IID" + TARGET_GITLAB_ORG_GITLAB_REPO: "$TARGET_GITLAB_ORG_GITLAB_REPO:-gitlab-org/gitlab" + TARGET_GITLAB_RAILS_SPEC_PROJECT: "$TARGET_GITLAB_RAILS_SPEC_PROJECT:-https://gitlab.com/api/v4/projects/278964" include: - template: Security/License-Scanning.gitlab-ci.yml @@ -493,13 +495,13 @@ start-rails-specs: script: - | curl --fail --request POST --header "PRIVATE-TOKEN: $GITLAB_PROJECT_TOKEN" \ - "https://gitlab.com/api/v4/projects/278964/repository/branches?ref=master&branch=$RAILS_BRANCH_FOR_JOB" + "${TARGET_GITLAB_RAILS_SPEC_PROJECT}/repository/branches?ref=master&branch=$RAILS_BRANCH_FOR_JOB" - | curl --fail --request PUT --header "PRIVATE-TOKEN: $GITLAB_PROJECT_TOKEN" \ --data "branch=$RAILS_BRANCH_FOR_JOB" \ --data "content=$CI_COMMIT_SHA" \ --data "commit_message=Updating GITALY_SERVER_VERSION to $CI_COMMIT_SHA" \ - "https://gitlab.com/api/v4/projects/278964/repository/files/GITALY_SERVER_VERSION" + "${TARGET_GITLAB_RAILS_SPEC_PROJECT}/repository/files/GITALY_SERVER_VERSION" environment: name: merge-requests/$RAILS_BRANCH_FOR_JOB on_stop: rails-specs-cleanup @@ -511,7 +513,7 @@ rails-specs: needs: ["start-rails-specs"] stage: qa trigger: - project: gitlab-org/gitlab + project: "${TARGET_GITLAB_ORG_GITLAB_REPO}" branch: "gitaly-ci-jobs-$CI_PIPELINE_IID" # Using $RAILS_BRANCH_FOR_JOB directly fails strategy: depend variables: @@ -527,7 +529,7 @@ rails-specs-cleanup: script: - | curl --fail --request DELETE --header "PRIVATE-TOKEN: $GITLAB_PROJECT_TOKEN" \ - "https://gitlab.com/api/v4/projects/278964/repository/branches/$RAILS_BRANCH_FOR_JOB" + "${TARGET_GITLAB_RAILS_SPEC_PROJECT}/repository/branches/$RAILS_BRANCH_FOR_JOB" environment: name: merge-requests/$RAILS_BRANCH_FOR_JOB action: stop -- GitLab