Skip to content
Snippets Groups Projects
Commit 4f75962b authored by DJ Mountney's avatar DJ Mountney
Browse files

Merge branch 'triggered-docker-tag' into 'master'

Use package version slug as triggered docker image tag

See merge request gitlab-org/omnibus-gitlab!4446
parents e4e07c23 7fbf17b9
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -334,12 +334,6 @@ Trigger:gitlab-docker:
stage: trigger-docker
script:
- if [ -n "$TRIGGERED_USER" ] && [ -n "$TRIGGER_SOURCE" ]; then echo "Pipeline triggered by $TRIGGERED_USER at $TRIGGER_SOURCE"; fi
# While triggering from omnibus repo in .com, we explicitly pass IMAGE_TAG
# variable, which will be used to tag the final Docker image.
# So, if IMAGE_TAG variable is empty, it means the trigger happened from
# either CE or EE repository. In that case, we can use the GITLAB_VERSION
# variable as IMAGE_TAG.
- if [ -z "${IMAGE_TAG}" ]; then export IMAGE_TAG=${GITLAB_VERSION}; fi
- bundle exec rake docker:build:image
- bundle exec rake docker:push:triggered
<<: *com-trigger-only
Loading
Loading
@@ -356,8 +350,6 @@ Trigger:qa-docker:
stage: trigger-docker
script:
- if [ -n "$TRIGGERED_USER" ] && [ -n "$TRIGGER_SOURCE" ]; then echo "Pipeline triggered by $TRIGGERED_USER at $TRIGGER_SOURCE"; fi
# For builds triggered from omnibus project, we are explicitly specifying IMAGE_TAG
- if [ -z "$IMAGE_TAG" ]; then export IMAGE_TAG=$GITLAB_VERSION; fi
- bundle exec rake qa:build
- bundle exec rake qa:push:triggered
<<: *com-trigger-only
Loading
Loading
@@ -369,8 +361,6 @@ Trigger:qa-test:
image: "${PUBLIC_BUILDER_IMAGE_REGISTRY}/ruby_docker:${BUILDER_IMAGE_REVISION}"
script:
- if [ -n "$TRIGGERED_USER" ] && [ -n "$TRIGGER_SOURCE" ]; then echo "Pipeline triggered by $TRIGGERED_USER at $TRIGGER_SOURCE"; fi
# For builds triggered from omnibus project, we are explicitly specifying IMAGE_TAG
- if [ -z "$IMAGE_TAG" ]; then export IMAGE_TAG=$GITLAB_VERSION; fi
- bundle exec rake qa:test
<<: *com-trigger-only
dependencies: []
Loading
Loading
Loading
Loading
@@ -27,7 +27,7 @@ module Build
end
 
def self.get_params(image: nil)
qa_image = image || "registry.gitlab.com/#{Build::Info::OMNIBUS_PROJECT_MIRROR_PATH}/gitlab-ee-qa:omnibus-#{Gitlab::Util.get_env('CI_COMMIT_SHA')}"
qa_image = image || "registry.gitlab.com/#{Build::Info::OMNIBUS_PROJECT_MIRROR_PATH}/gitlab-ee-qa:#{Build::Info.docker_tag}"
{
'ref' => 'master',
'token' => Gitlab::Util.get_env('HA_VALIDATE_TOKEN'),
Loading
Loading
Loading
Loading
@@ -65,7 +65,7 @@ module Build
end
 
def docker_tag
Info.release_version.tr('+', '-')
Gitlab::Util.get_env('IMAGE_TAG') || Info.release_version.tr('+', '-')
end
 
def gitlab_version
Loading
Loading
@@ -190,14 +190,7 @@ module Build
end
 
def image_reference
if Gitlab::Util.get_env('CI_PROJECT_PATH') == OMNIBUS_PROJECT_MIRROR_PATH && %w[trigger pipeline].include?(Gitlab::Util.get_env('CI_PIPELINE_SOURCE'))
"#{Build::GitlabImage.gitlab_registry_image_address}:#{Gitlab::Util.get_env('IMAGE_TAG')}"
elsif Build::Check.is_nightly? || Build::Check.on_tag?
# We push nightly images to both dockerhub and gitlab registry
"#{Build::GitlabImage.gitlab_registry_image_address}:#{Info.docker_tag}"
else
abort 'unknown pipeline type: only support triggered/nightly/tag pipeline'
end
"#{Build::GitlabImage.gitlab_registry_image_address}:#{Info.docker_tag}"
end
 
def deploy_env
Loading
Loading
Loading
Loading
@@ -19,7 +19,6 @@ module Build
"variables[BUILDER_IMAGE_REGISTRY]" => Gitlab::Util.get_env('BUILDER_IMAGE_REGISTRY'),
"variables[PUBLIC_BUILDER_IMAGE_REGISTRY]" => Gitlab::Util.get_env('PUBLIC_BUILDER_IMAGE_REGISTRY'),
"variables[COMPILE_ASSETS]" => Gitlab::Util.get_env('COMPILE_ASSETS'),
"variables[IMAGE_TAG]" => "omnibus-#{Gitlab::Util.get_env('CI_COMMIT_SHA')}",
"variables[ee]" => Gitlab::Util.get_env("ee") || "false",
"variables[TRIGGERED_USER]" => Gitlab::Util.get_env("TRIGGERED_USER") || Gitlab::Util.get_env("GITLAB_USER_NAME"),
"variables[TRIGGER_SOURCE]" => Gitlab::Util.get_env('CI_JOB_URL'),
Loading
Loading
Loading
Loading
@@ -56,7 +56,7 @@ namespace :docker do
 
desc "Push triggered Docker Image to GitLab Registry"
task :triggered do
Build::GitlabImage.tag_and_push_to_gitlab_registry(Gitlab::Util.get_env('IMAGE_TAG'))
Build::GitlabImage.tag_and_push_to_gitlab_registry(Build::Info.docker_tag)
end
end
 
Loading
Loading
Loading
Loading
@@ -53,13 +53,13 @@ namespace :qa do
 
desc "Push triggered version of gitlab-{ce,ee}-qa to the GitLab registry"
task :triggered do
Build::QAImage.tag_and_push_to_gitlab_registry(Gitlab::Util.get_env('IMAGE_TAG'))
Build::QAImage.tag_and_push_to_gitlab_registry(Build::Info.docker_tag)
end
end
 
desc "Run QA tests"
task :test do
image_address = Build::GitlabImage.gitlab_registry_image_address(tag: Gitlab::Util.get_env('IMAGE_TAG'))
image_address = Build::GitlabImage.gitlab_registry_image_address(tag: Build::Info.docker_tag)
Build::QATrigger.invoke!(image: image_address, post_comment: true).wait!
end
 
Loading
Loading
Loading
Loading
@@ -6,6 +6,7 @@ RSpec.describe Build::HA::ValidateTrigger do
allow(ENV).to receive(:[]).and_call_original
allow(ENV).to receive(:[]).with('CI_COMMIT_SHA').and_return('11111111111111111')
allow(ENV).to receive(:[]).with('HA_VALIDATE_TOKEN').and_return('faketoken')
allow(Build::Info).to receive(:docker_tag).and_return('13.2.0-ce-0')
allow(Build::Info).to receive(:fetch_pipeline_jobs).and_return(
[
{
Loading
Loading
@@ -34,7 +35,7 @@ RSpec.describe Build::HA::ValidateTrigger do
{
'ref' => 'master',
'token' => 'faketoken',
'variables[QA_IMAGE]' => 'registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee-qa:omnibus-11111111111111111',
'variables[QA_IMAGE]' => 'registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee-qa:13.2.0-ce-0',
'variables[OMNIBUS_JOB_ID]' => 3
}
)
Loading
Loading
Loading
Loading
@@ -66,6 +66,11 @@ RSpec.describe Build::Info do
it 'returns package version when regular build' do
expect(described_class.docker_tag).to eq('12.121.12-ce.1')
end
it 'respects IMAGE_TAG if set' do
allow(ENV).to receive(:[]).with('IMAGE_TAG').and_return('foobar')
expect(described_class.docker_tag).to eq('foobar')
end
end
 
# Specs for latest_tag and for latest_stable_tag are really useful since we
Loading
Loading
@@ -208,60 +213,6 @@ RSpec.describe Build::Info do
end
end
 
describe '.image_reference' do
before do
allow(ENV).to receive(:[]).and_call_original
allow(ENV).to receive(:[]).with('IMAGE_TAG').and_return('foo')
allow(Build::GitlabImage).to receive(:gitlab_registry_image_address).and_return('mock.gitlab.com/omnibus')
allow(Build::Info).to receive(:docker_tag).and_return('bar')
end
context 'On a triggered pipeline' do
before do
allow(ENV).to receive(:[]).with('CI_PROJECT_PATH').and_return('gitlab-org/build/omnibus-gitlab-mirror')
allow(ENV).to receive(:[]).with('CI_PIPELINE_SOURCE').and_return('trigger')
end
it 'returns image reference correctly' do
expect(described_class.image_reference).to eq("mock.gitlab.com/omnibus:foo")
end
end
context 'On a nightly pipeline' do
before do
allow(Build::Check).to receive(:is_nightly?).and_return(true)
end
it 'returns image reference correctly' do
expect(described_class.image_reference).to eq("mock.gitlab.com/omnibus:bar")
end
end
context 'On a tag pipeline' do
before do
allow(Build::Check).to receive(:is_nightly?).and_return(false)
allow(Build::Check).to receive(:on_tag?).and_return(true)
end
it 'returns image reference correctly' do
expect(described_class.image_reference).to eq("mock.gitlab.com/omnibus:bar")
end
end
context 'On a regular pipeline' do
before do
allow(Build::Check).to receive(:is_nightly?).and_return(false)
allow(Build::Check).to receive(:on_tag?).and_return(false)
end
it 'raises error' do
expect { described_class.image_reference }
.to raise_error(SystemExit,
/unknown pipeline type: only support triggered\/nightly\/tag pipeline/)
end
end
end
describe '.deploy_env' do
before do
allow(ENV).to receive(:[]).with('AUTO_DEPLOY_ENVIRONMENT').and_return('ad')
Loading
Loading
Loading
Loading
@@ -120,6 +120,7 @@ RSpec.describe 'docker', type: :rake do
it 'pushes triggered images correctly' do
allow(ENV).to receive(:[]).with('CI_REGISTRY_IMAGE').and_return('registry.gitlab.com/gitlab-org/omnibus-gitlab')
allow(ENV).to receive(:[]).with("IMAGE_TAG").and_return("omnibus-12345")
allow(Build::Info).to receive(:docker_tag).and_call_original
 
expect(dummy_image).to receive(:push).with(dummy_creds, repo_tag: 'registry.gitlab.com/gitlab-org/omnibus-gitlab/gitlab-ce:omnibus-12345')
Rake::Task['docker:push:triggered'].invoke
Loading
Loading
Loading
Loading
@@ -135,6 +135,7 @@ RSpec.describe 'qa', type: :rake do
allow(ENV).to receive(:[]).with('TOP_UPSTREAM_MERGE_REQUEST_IID').and_return("12121")
allow(DockerOperations).to receive(:build).and_return(true)
allow(Build::QA).to receive(:get_gitlab_repo).and_return("/tmp/gitlab.1234/qa")
allow(Build::Info).to receive(:release_version).and_return('13.2.0+ce.0')
allow(Build::GitlabImage).to receive(:gitlab_registry_image_address).and_return("registry.gitlab.com/gitlab-ce:latest")
allow(Build::GitlabImage).to receive(:tag_and_push_to_gitlab_registry).and_return(true)
allow(Build::QAImage).to receive(:gitlab_registry_image_address).and_return(gitlab_registry_image_address)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment