lib/gitlab/qa/release.rb in gitlab-qa-8.3.1 vs lib/gitlab/qa/release.rb in gitlab-qa-8.3.2

- old
+ new

@@ -7,23 +7,23 @@ \A (?<edition>ce|ee) (-qa)? (:(?<tag>.+))? \z - /xi + /xi.freeze CUSTOM_GITLAB_IMAGE_REGEX = %r{ \A (?<image_without_tag> - (?<registry>[^\/:]+(:(?<port>\d+))?) - .+ + (?<registry>[^/:]+(:(?<port>\d+))?) + (?<project>.+) gitlab- (?<edition>ce|ee) ) (-qa)? (:(?<tag>.+))? \z - }xi + }xi.freeze # Official dev tag example: # 12.5.4(-rc42)-ee # |-------------|--| # | | @@ -33,11 +33,11 @@ # version DEV_OFFICIAL_TAG_REGEX = / \A (?<version>\d+\.\d+.\d+(?:-rc\d+)?)-(?<edition>ce|ee) \z - /xi + /xi.freeze # Dev tag example: # 12.1.201906121026-325a6632895.b340d0bd35d # |----|------------|-----------|-----------| # | | | | @@ -45,13 +45,13 @@ # | | gitlab-ee ref # | timestamp # version DEV_TAG_REGEX = / \A - (?<version>\d+\.\d+(.\d+)?)\.(?<timestamp>\d+)\-(?<gitlab_ref>[A-Za-z0-9]+)\.(?<omnibus_ref>[A-Za-z0-9]+) + (?<version>\d+\.\d+(.\d+)?)\.(?<timestamp>\d+)-(?<gitlab_ref>[A-Za-z0-9]+)\.(?<omnibus_ref>[A-Za-z0-9]+) \z - /xi + /xi.freeze DEFAULT_TAG = 'latest' DEFAULT_CANONICAL_TAG = 'nightly' DEV_REGISTRY = 'dev.gitlab.org:5005' COM_REGISTRY = 'registry.gitlab.com' @@ -61,12 +61,13 @@ attr_reader :release attr_writer :tag def initialize(release) @release = release.to_s.downcase + return if valid? - raise InvalidImageNameError, "The release image name '#{@release}' does not have the expected format." unless valid? + raise InvalidImageNameError, "The release image name '#{@release}' does not have the expected format." end def to_s "#{image}:#{tag}" end @@ -104,11 +105,18 @@ release.match(CUSTOM_GITLAB_IMAGE_REGEX)[:image_without_tag] end end def qa_image - "#{image}-qa" + @qa_image ||= if omnibus_mirror? + omnibus_project = image.match(CUSTOM_GITLAB_IMAGE_REGEX)[:project] + gitlab_project = "/gitlab-org/gitlab/" + + "#{image.gsub(omnibus_project, gitlab_project)}-qa" + else + "#{image}-qa" + end end def project_name @project_name ||= if canonical? @@ -131,11 +139,11 @@ # Tag scheme for gitlab-{ce,ee}-qa images is like 11.1.0-rc12-ee def qa_tag if dev_gitlab_org? && (match_data = tag.match(DEV_TAG_REGEX)) "#{match_data[:version]}-#{match_data[:gitlab_ref]}" else - tag.sub(/[-\.]([ce]e)(\.(\d+))?\z/, '-\1') + tag.sub(/[-.]([ce]e)(\.(\d+))?\z/, '-\1') end end def login_params return if Runtime::Env.skip_pull? @@ -156,9 +164,10 @@ else Runtime::Env.require_qa_access_token! [Runtime::Env.gitlab_username, Runtime::Env.qa_access_token] end + { username: username, password: password, registry: COM_REGISTRY }