Commit 08c8a8bc authored by John Jarvis's avatar John Jarvis Committed by Robert Speicher

Update the AUTO_DEPLOY CI variable when branches are created

parent c6ebcc91
......@@ -76,6 +76,7 @@ require 'release_tools/project/gitlab_provisioner'
require 'release_tools/project/helm_gitlab'
require 'release_tools/project/omnibus_gitlab'
require 'release_tools/project/release/tasks'
require 'release_tools/project/release_tools'
require 'release_tools/qa'
require 'release_tools/qa/formatters/merge_requests_formatter'
require 'release_tools/qa/issuable_omitter_by_labels'
......
......@@ -13,8 +13,10 @@ module ReleaseTools
def_delegator :client, :file_contents
def_delegator :client, :job_play
def_delegator :client, :create_merge_request_comment
def_delegator :client, :create_group_label
def_delegator :client, :create_merge_request_comment
def_delegator :client, :create_variable
def_delegator :client, :update_variable
end
class MissingMilestone
......
# frozen_string_literal: true
module ReleaseTools
module Project
class ReleaseTools < BaseProject
REMOTES = {
gitlab: 'git@gitlab.com:gitlab-org/release-tools.git'
}.freeze
end
end
end
......@@ -5,6 +5,7 @@ module ReleaseTools
class AutoDeployBranchService
include BranchCreation
PIPELINE_ID_PADDING = 7
CI_VAR_AUTO_DEPLOY = 'AUTO_DEPLOY_BRANCH'
def initialize(pipeline_id)
@pipeline_id = pipeline_id.to_s.rjust(PIPELINE_ID_PADDING, '0')
......@@ -20,6 +21,7 @@ module ReleaseTools
create_branch_from_ref(Project::Deployer, branch_name, ref_deployer, gitlab_ops_client)
create_branch_from_ref(Project::GitlabEe, branch_name, ref_ee)
create_branch_from_ref(Project::OmnibusGitlab, branch_name, ref_omnibus)
update_auto_deploy_ci
end
private
......@@ -31,6 +33,12 @@ module ReleaseTools
def branch_name
"#{version}-auto-deploy-#{@pipeline_id}-ee"
end
def update_auto_deploy_ci
gitlab_client.update_variable(Project::ReleaseTools.path, CI_VAR_AUTO_DEPLOY, branch_name)
rescue Gitlab::Error::NotFound
gitlab_client.create_variable(Project::ReleaseTools.path, CI_VAR_AUTO_DEPLOY, branch_name)
end
end
end
end
......@@ -10,7 +10,7 @@ describe ReleaseTools::Services::AutoDeployBranchService do
end
end
let(:internal_client) { double('ReleaseTools::GitlabClient', current_milestone: double(title: '11.10')) }
let(:internal_client) { double('ReleaseTools::GitlabClient', current_milestone: double(title: '11.10'), update_variable: double) }
let(:internal_client_ops) { spy('ReleaseTools::GitlabOpsClient') }
let(:branch_commit) { double(latest_successful: double(id: '1234')) }
......@@ -39,7 +39,11 @@ describe ReleaseTools::Services::AutoDeployBranchService do
'1234',
ReleaseTools::Project::Deployer
)
expect(internal_client).to receive(:update_variable).with(
'gitlab-org/release-tools',
'AUTO_DEPLOY_BRANCH',
'11-10-auto-deploy-0009000-ee'
)
without_dry_run do
service.create_auto_deploy_branches!
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment