Commit fdad9b67 authored by John Skarbek's avatar John Skarbek Committed by Robert Speicher

Grabs and reports the versions of our components for builds

* We need to send the versions of the various gitlab subcomponents
* this will read in the files at the level of the commit selected for a
green build
* We then send in those versions to the trigger omnibus build
parent 056776f6
......@@ -34,32 +34,48 @@ end
namespace :green_master do
desc "Trigger a green master build for EE"
task :ee, [:trigger_build] do |_t, args|
commit = ReleaseTools::Commits.new(ReleaseTools::Project::GitlabEe).latest_successful
project = ReleaseTools::Project::GitlabEe
commit = ReleaseTools::Commits.new(project).latest_successful
raise 'No recent master builds have green pipelines' if commit.nil?
$stdout.puts "Found EE Green Master at #{commit.id}"
versions = ReleaseTools::ComponentVersions.get(project, commit)
versions.each do |component, version|
puts "#{component}: #{version}"
end
if args.trigger_build
ReleaseTools::Pipeline.new(
ReleaseTools::Project::GitlabEe,
commit.id
project,
commit.id,
versions
).trigger
end
end
desc "Trigger a green master build for CE"
task :ce, [:trigger_build] do |_t, args|
commit = ReleaseTools::Commits.new(ReleaseTools::Project::GitlabCe).latest_successful
project = ReleaseTools::Project::GitlabCe
commit = ReleaseTools::Commits.new(project).latest_successful
raise 'No recent master builds have green pipelines' if commit.nil?
$stdout.puts "Found CE Green Master at #{commit.id}"
versions = ReleaseTools::ComponentVersions.get(project, commit)
versions.each do |component, version|
puts "#{component}: #{version}"
end
if args.trigger_build
ReleaseTools::Pipeline.new(
ReleaseTools::Project::GitlabCe,
commit.id
project,
commit.id,
versions
).trigger
end
end
......
......@@ -48,6 +48,7 @@ require 'release_tools/cherry_pick/result'
require 'release_tools/cherry_pick/service'
require 'release_tools/commit_author'
require 'release_tools/commits'
require 'release_tools/component_versions'
require 'release_tools/gitlab_client'
require 'release_tools/gitlab_dev_client'
require 'release_tools/helm/chart_file'
......
# frozen_string_literal: true
module ReleaseTools
class ComponentVersions
FILES = %w[GITALY_SERVER GITLAB_PAGES GITLAB_SHELL GITLAB_WORKHORSE].freeze
def self.get(project, commit)
versions = {}
FILES.each do |x|
versions["#{x}_VERSION"] = ReleaseTools::GitlabClient.file_contents(
project.path,
"#{x}_VERSION",
commit.id
).chomp
end
versions
end
end
end
......@@ -11,6 +11,7 @@ module ReleaseTools
def_delegator :client, :commits
def_delegator :client, :pipelines
def_delegator :client, :pipeline_jobs
def_delegator :client, :file_contents
def_delegator :client, :job_play
def_delegator :client, :create_merge_request_comment
......
......@@ -2,10 +2,11 @@ module ReleaseTools
class Pipeline
attr_reader :project, :sha
def initialize(project, sha)
def initialize(project, sha, versions)
@project = project
@sha = sha
@token = ENV.fetch('OMNIBUS_BUILD_TRIGGER_TOKEN') { |name| raise "Missing environment variable `#{name}`" }
@versions = versions
end
def trigger
......@@ -13,10 +14,8 @@ module ReleaseTools
trigger = ReleaseTools::GitlabDevClient.run_trigger(
ReleaseTools::Project::OmnibusGitlab,
@token,
"master",
GITLAB_VERSION: sha,
NIGHTLY: "true",
ee: project == ReleaseTools::Project::GitlabEe
'master',
build_variables
)
$stdout.puts "Pipeline triggered: #{trigger.web_url}"
wait(trigger.id)
......@@ -49,5 +48,15 @@ module ReleaseTools
$stdout.flush
end
end
private
def build_variables
@versions.merge(
'GITLAB_VERSION' => @sha,
'NIGHTLY' => 'true',
'ee' => @project == ReleaseTools::Project::GitlabEe
)
end
end
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