diff --git a/lib/gitlab/qa/component/specs.rb b/lib/gitlab/qa/component/specs.rb index 2cc7e8422577513d7f0df39c36cd0a1d070b5190..677968f435d9056984da66a4fe9839837ba66f89 100644 --- a/lib/gitlab/qa/component/specs.rb +++ b/lib/gitlab/qa/component/specs.rb @@ -149,7 +149,6 @@ module Gitlab def docker_pull_qa_image_if_needed @docker.login(**release.login_params) if release.login_params - @docker.pull(image: qa_image) unless Runtime::Env.skip_pull? end diff --git a/lib/gitlab/qa/release.rb b/lib/gitlab/qa/release.rb index 027dbf103083da81fda8e73a53bea6c3366d11c1..2ec170ade34be7af50e580e3c4b618bd489ae221 100644 --- a/lib/gitlab/qa/release.rb +++ b/lib/gitlab/qa/release.rb @@ -59,6 +59,7 @@ module Gitlab DEFAULT_CANONICAL_TAG = 'nightly' DEV_REGISTRY = Gitlab::QA::Runtime::Env.qa_dev_registry COM_REGISTRY = Gitlab::QA::Runtime::Env.qa_com_registry + CUSTOM_REGISTRY = Gitlab::QA::Runtime::Env.qa_custom_registry InvalidImageNameError = Class.new(RuntimeError) @@ -110,12 +111,21 @@ module Gitlab end end + def assing_omnibus_mirror_fork_project + omnibus_project = image.match(CUSTOM_GITLAB_IMAGE_REGEX)[:project] + gitlab_project = "/registry.gitlab.com/gitlab-com/ops-sub-department/aws-gitlab-ai-integration/gitlab/" + + "#{image.gsub(omnibus_project, gitlab_project)}-qa" + end + def qa_image @qa_image ||= if omnibus_mirror? omnibus_project = image.match(CUSTOM_GITLAB_IMAGE_REGEX)[:project] gitlab_project = ci_project_path ? "/#{ci_project_path}/" : "/gitlab-org/gitlab/" "#{image.gsub(omnibus_project, gitlab_project)}-qa" + elsif omnibus_mirror_fork? + assing_omnibus_mirror_fork_project else "#{image}-qa" end @@ -162,6 +172,12 @@ module Gitlab } elsif omnibus_mirror? || omnibus_security? omnibus_login_params + elsif omnibus_mirror_fork? + { + username: Runtime::Env.gitlab_custom_username, + password: Runtime::Env.gitlab_custom_username_token, + registry: CUSTOM_REGISTRY + } end populate_registry_env_vars(params) @@ -203,6 +219,10 @@ module Gitlab image.start_with?("#{COM_REGISTRY}/gitlab-org/build/omnibus-gitlab-mirror/") end + def omnibus_mirror_fork? + image.start_with?("#{COM_REGISTRY}/gitlab-com/ops-sub-department/aws-gitlab-ai-integration/omnibus-gitlab-mirror") + end + def omnibus_security? image.start_with?("#{COM_REGISTRY}/gitlab-org/security/omnibus-gitlab/") end diff --git a/lib/gitlab/qa/runtime/env.rb b/lib/gitlab/qa/runtime/env.rb index 0bcaed008036de5cd59bf6a55016ea3fc099a972..92755824d5eb6c14c2c1b7fb8cdef702198b2fab 100644 --- a/lib/gitlab/qa/runtime/env.rb +++ b/lib/gitlab/qa/runtime/env.rb @@ -219,6 +219,14 @@ module Gitlab env_var_value_if_defined('GITLAB_DEV_USERNAME') || 'gitlab-qa-bot' end + def gitlab_custom_username + env_var_value_if_defined('GITLAB_CUSTOM_USERNAME') + end + + def gitlab_custom_username_token + env_var_value_if_defined('GITLAB_CUSTOM_ACCESS_TOKEN') + end + def run_id @run_id ||= "gitlab-qa-run-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}-#{SecureRandom.hex(4)}" end @@ -432,6 +440,10 @@ module Gitlab env_var_value_if_defined('QA_COM_REGISTRY') || 'registry.gitlab.com' end + def qa_custom_registry + env_var_value_if_defined('QA_CUSTOM_REGISTRY') || 'registry.gitlab.com' + end + def gitlab_license_mode env_var_value_if_defined('GITLAB_LICENSE_MODE') end