From bf8289ab549324cadec427b8f9a5ae5335453761 Mon Sep 17 00:00:00 2001 From: "Balasankar \"Balu\" C" Date: Thu, 14 Dec 2017 14:02:08 +0530 Subject: [PATCH 1/6] Pass info about who started the job and which job triggered it --- scripts/trigger-build-omnibus | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/trigger-build-omnibus b/scripts/trigger-build-omnibus index 4ff0e8e10b7..bd243a4903f 100755 --- a/scripts/trigger-build-omnibus +++ b/scripts/trigger-build-omnibus @@ -39,7 +39,9 @@ module Omnibus "ref" => ENV["OMNIBUS_BRANCH"] || "master", "variables[GITLAB_VERSION]" => ENV["CI_COMMIT_SHA"], "variables[ALTERNATIVE_SOURCES]" => true, - "variables[ee]" => ee? ? 'true' : 'false' + "variables[ee]" => ee? ? 'true' : 'false', + "variables[TRIGGERED_USER]" => ENV["GITLAB_USER_NAME"], + "variables[TRIGGER_SOURCE_JOB]" => "https://gitlab.com/gitlab-org/#{ENV['CI_PROJECT_NAME']}/-/jobs/#{ENV['CI_JOB_ID']}" } end From 963b007b01bf88d11247457f2f042409b263a1aa Mon Sep 17 00:00:00 2001 From: "Balasankar \"Balu\" C" Date: Thu, 14 Dec 2017 15:33:12 +0530 Subject: [PATCH 2/6] Use temp branch --- scripts/trigger-build-omnibus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/trigger-build-omnibus b/scripts/trigger-build-omnibus index bd243a4903f..b64f1824fd7 100755 --- a/scripts/trigger-build-omnibus +++ b/scripts/trigger-build-omnibus @@ -36,7 +36,7 @@ module Omnibus def env_params { - "ref" => ENV["OMNIBUS_BRANCH"] || "master", + "ref" => "trigger-user-pipeline-info", "variables[GITLAB_VERSION]" => ENV["CI_COMMIT_SHA"], "variables[ALTERNATIVE_SOURCES]" => true, "variables[ee]" => ee? ? 'true' : 'false', From ab78b570f49f6b1dd14a14803f41e7447c936946 Mon Sep 17 00:00:00 2001 From: "Balasankar \"Balu\" C" Date: Thu, 14 Dec 2017 17:43:06 +0530 Subject: [PATCH 3/6] Prettify --- scripts/trigger-build-omnibus | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/trigger-build-omnibus b/scripts/trigger-build-omnibus index b64f1824fd7..98d03780a0c 100755 --- a/scripts/trigger-build-omnibus +++ b/scripts/trigger-build-omnibus @@ -21,6 +21,7 @@ module Omnibus if id puts "Triggered https://gitlab.com/#{Omnibus::PROJECT_PATH}/pipelines/#{id}" + puts "Waiting for downstream pipeline status" else raise "Trigger failed! The response from the trigger is: #{res.body}" end @@ -36,12 +37,12 @@ module Omnibus def env_params { - "ref" => "trigger-user-pipeline-info", + "ref" => ENV["OMNIBUS_BRANCH"] || "master", "variables[GITLAB_VERSION]" => ENV["CI_COMMIT_SHA"], "variables[ALTERNATIVE_SOURCES]" => true, "variables[ee]" => ee? ? 'true' : 'false', "variables[TRIGGERED_USER]" => ENV["GITLAB_USER_NAME"], - "variables[TRIGGER_SOURCE_JOB]" => "https://gitlab.com/gitlab-org/#{ENV['CI_PROJECT_NAME']}/-/jobs/#{ENV['CI_JOB_ID']}" + "variables[TRIGGER_SOURCE]" => "https://gitlab.com/gitlab-org/#{ENV['CI_PROJECT_NAME']}/-/jobs/#{ENV['CI_JOB_ID']}" } end @@ -65,13 +66,17 @@ module Omnibus def wait! loop do - raise 'Pipeline timeout!' if timeout? + if timeout? + puts "\nWaited for #{((Time.now.to_i - @start)/60)} minutes" + raise 'Pipeline timeout!' + end case status when :created, :pending, :running - puts "Waiting another #{INTERVAL} seconds ..." + print "." sleep INTERVAL when :success + puts "\nWaited for #{((Time.now.to_i - @start)/60)} minutes" puts "Omnibus pipeline succeeded!" break else From f4030dc35182223f6254343f05d2c8196c702a77 Mon Sep 17 00:00:00 2001 From: "Balasankar \"Balu\" C" Date: Thu, 14 Dec 2017 18:00:45 +0530 Subject: [PATCH 4/6] Improve language --- scripts/trigger-build-omnibus | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/trigger-build-omnibus b/scripts/trigger-build-omnibus index 98d03780a0c..44102245d73 100755 --- a/scripts/trigger-build-omnibus +++ b/scripts/trigger-build-omnibus @@ -67,8 +67,7 @@ module Omnibus def wait! loop do if timeout? - puts "\nWaited for #{((Time.now.to_i - @start)/60)} minutes" - raise 'Pipeline timeout!' + raise "Pipeline timed out after waiting for #{duration} minutes!" end case status @@ -76,8 +75,7 @@ module Omnibus print "." sleep INTERVAL when :success - puts "\nWaited for #{((Time.now.to_i - @start)/60)} minutes" - puts "Omnibus pipeline succeeded!" + puts "Omnibus pipeline succeeded in #{duration} minutes!" break else raise "Omnibus pipeline did not succeed!" @@ -91,6 +89,10 @@ module Omnibus Time.now.to_i > (@start + MAX_DURATION) end + def duration + (Time.now.to_i - @start)/60 + end + def status req = Net::HTTP::Get.new(@uri) req['PRIVATE-TOKEN'] = ENV['GITLAB_QA_ACCESS_TOKEN'] From fe95db625d2fe9378b3339435a08e27fb460ee4e Mon Sep 17 00:00:00 2001 From: "Balasankar \"Balu\" C" Date: Thu, 14 Dec 2017 18:09:13 +0530 Subject: [PATCH 5/6] Use guard clause --- scripts/trigger-build-omnibus | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/trigger-build-omnibus b/scripts/trigger-build-omnibus index 44102245d73..78f01c0e063 100755 --- a/scripts/trigger-build-omnibus +++ b/scripts/trigger-build-omnibus @@ -66,9 +66,7 @@ module Omnibus def wait! loop do - if timeout? - raise "Pipeline timed out after waiting for #{duration} minutes!" - end + raise "Pipeline timed out after waiting for #{duration} minutes!" if timeout? case status when :created, :pending, :running From 3bbdb8b230198766f3d3d18fbdec7728d0e2b610 Mon Sep 17 00:00:00 2001 From: "Balasankar \"Balu\" C" Date: Thu, 14 Dec 2017 19:18:18 +0530 Subject: [PATCH 6/6] Make rubocop happy --- scripts/trigger-build-omnibus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/trigger-build-omnibus b/scripts/trigger-build-omnibus index 78f01c0e063..85ea4aa74ac 100755 --- a/scripts/trigger-build-omnibus +++ b/scripts/trigger-build-omnibus @@ -88,7 +88,7 @@ module Omnibus end def duration - (Time.now.to_i - @start)/60 + (Time.now.to_i - @start) / 60 end def status