Merge branch 'trigger-user-pipeline-info' into 'master'

Pass info regarding the user and job that initiated a trigger

See merge request gitlab-org/gitlab-ce!15934
This commit is contained in:
Grzegorz Bizon 2017-12-15 08:26:51 +00:00
commit c96e2edc10

View file

@ -21,6 +21,7 @@ module Omnibus
if id if id
puts "Triggered https://gitlab.com/#{Omnibus::PROJECT_PATH}/pipelines/#{id}" puts "Triggered https://gitlab.com/#{Omnibus::PROJECT_PATH}/pipelines/#{id}"
puts "Waiting for downstream pipeline status"
else else
raise "Trigger failed! The response from the trigger is: #{res.body}" raise "Trigger failed! The response from the trigger is: #{res.body}"
end end
@ -39,7 +40,9 @@ module Omnibus
"ref" => ENV["OMNIBUS_BRANCH"] || "master", "ref" => ENV["OMNIBUS_BRANCH"] || "master",
"variables[GITLAB_VERSION]" => ENV["CI_COMMIT_SHA"], "variables[GITLAB_VERSION]" => ENV["CI_COMMIT_SHA"],
"variables[ALTERNATIVE_SOURCES]" => true, "variables[ALTERNATIVE_SOURCES]" => true,
"variables[ee]" => ee? ? 'true' : 'false' "variables[ee]" => ee? ? 'true' : 'false',
"variables[TRIGGERED_USER]" => ENV["GITLAB_USER_NAME"],
"variables[TRIGGER_SOURCE]" => "https://gitlab.com/gitlab-org/#{ENV['CI_PROJECT_NAME']}/-/jobs/#{ENV['CI_JOB_ID']}"
} }
end end
@ -63,14 +66,14 @@ module Omnibus
def wait! def wait!
loop do loop do
raise 'Pipeline timeout!' if timeout? raise "Pipeline timed out after waiting for #{duration} minutes!" if timeout?
case status case status
when :created, :pending, :running when :created, :pending, :running
puts "Waiting another #{INTERVAL} seconds ..." print "."
sleep INTERVAL sleep INTERVAL
when :success when :success
puts "Omnibus pipeline succeeded!" puts "Omnibus pipeline succeeded in #{duration} minutes!"
break break
else else
raise "Omnibus pipeline did not succeed!" raise "Omnibus pipeline did not succeed!"
@ -84,6 +87,10 @@ module Omnibus
Time.now.to_i > (@start + MAX_DURATION) Time.now.to_i > (@start + MAX_DURATION)
end end
def duration
(Time.now.to_i - @start) / 60
end
def status def status
req = Net::HTTP::Get.new(@uri) req = Net::HTTP::Get.new(@uri)
req['PRIVATE-TOKEN'] = ENV['GITLAB_QA_ACCESS_TOKEN'] req['PRIVATE-TOKEN'] = ENV['GITLAB_QA_ACCESS_TOKEN']