summaryrefslogtreecommitdiff
path: root/scripts/trigger-build
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/trigger-build')
-rwxr-xr-xscripts/trigger-build26
1 files changed, 14 insertions, 12 deletions
diff --git a/scripts/trigger-build b/scripts/trigger-build
index 7fc550d86ee..ab6dcc63e11 100755
--- a/scripts/trigger-build
+++ b/scripts/trigger-build
@@ -138,8 +138,12 @@ module Trigger
def extra_variables
# Use CI_MERGE_REQUEST_SOURCE_BRANCH_SHA for omnibus checkouts due to pipeline for merged results
# and fallback to CI_COMMIT_SHA for the `detached` pipelines.
+ # We also set IMAGE_TAG so the GitLab and QA docker images are tagged with
+ # that SHA.
+ source_sha = Trigger.non_empty_variable_value('CI_MERGE_REQUEST_SOURCE_BRANCH_SHA') || ENV['CI_COMMIT_SHA']
{
- 'GITLAB_VERSION' => Trigger.non_empty_variable_value('CI_MERGE_REQUEST_SOURCE_BRANCH_SHA') || ENV['CI_COMMIT_SHA'],
+ 'GITLAB_VERSION' => source_sha,
+ 'IMAGE_TAG' => source_sha,
'ALTERNATIVE_SOURCES' => 'true',
'SECURITY_SOURCES' => Trigger.security? ? 'true' : 'false',
'ee' => Trigger.ee? ? 'true' : 'false',
@@ -317,8 +321,6 @@ module Trigger
INTERVAL = 60 # seconds
MAX_DURATION = 3600 * 3 # 3 hours
- attr_reader :project, :id
-
def self.unscoped_class_name
name.split('::').last
end
@@ -330,34 +332,30 @@ module Trigger
def initialize(project, id)
@project = project
@id = id
- @start = Time.now.to_i
+ @start_time = Time.now.to_i
end
def wait!
- loop do
- raise "#{self.class.unscoped_class_name} timed out after waiting for #{duration} minutes!" if timeout?
-
+ (MAX_DURATION / INTERVAL).times do
case status
when :created, :pending, :running
print "."
sleep INTERVAL
when :success
puts "#{self.class.unscoped_class_name} succeeded in #{duration} minutes!"
- break
+ return
else
raise "#{self.class.unscoped_class_name} did not succeed!"
end
STDOUT.flush
end
- end
- def timeout?
- Time.now.to_i > (@start + MAX_DURATION)
+ raise "#{self.class.unscoped_class_name} timed out after waiting for #{duration} minutes!"
end
def duration
- (Time.now.to_i - @start) / 60
+ (Time.now.to_i - start_time) / 60
end
def status
@@ -368,6 +366,10 @@ module Trigger
# timeout anyway.
:running
end
+
+ private
+
+ attr_reader :project, :id, :start_time
end
Job = Class.new(Pipeline)