diff options
author | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
commit | 62d7990b9bb30cf33ed87017c5c633d1cccc75c2 (patch) | |
tree | c3e1b69c58a412ba1c6f50a0337a23d9f9d6e1a4 /scripts/trigger-build | |
parent | f6453eca992a9c142268e78ac782cef98110d183 (diff) | |
download | gitlab-ce-tc-standard-gem.tar.gz |
Ran standardrb --fix on the whole codebasetc-standard-gem
Inspired by https://twitter.com/searls/status/1101137953743613952 I
decided to try https://github.com/testdouble/standard on our codebase.
It's opinionated, but at least it's a _standard_.
Diffstat (limited to 'scripts/trigger-build')
-rwxr-xr-x | scripts/trigger-build | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/scripts/trigger-build b/scripts/trigger-build index 9dbafffddfc..00b7c0caf39 100755 --- a/scripts/trigger-build +++ b/scripts/trigger-build @@ -1,18 +1,18 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require 'gitlab' +require "gitlab" # # Configure credentials to be used with gitlab gem # Gitlab.configure do |config| - config.endpoint = 'https://gitlab.com/api/v4' + config.endpoint = "https://gitlab.com/api/v4" end module Trigger def self.ee? - ENV['CI_PROJECT_NAME'] == 'gitlab-ee' || File.exist?('CHANGELOG-EE.md') + ENV["CI_PROJECT_NAME"] == "gitlab-ee" || File.exist?("CHANGELOG-EE.md") end class Base @@ -21,7 +21,8 @@ module Trigger downstream_project_path, trigger_token, ref, - variables) + variables + ) puts "Triggered downstream pipeline: #{pipeline.web_url}\n" puts "Waiting for downstream pipeline status" @@ -68,12 +69,12 @@ module Trigger def base_variables { - 'GITLAB_REF_SLUG' => ENV['CI_COMMIT_TAG'] ? ENV['CI_COMMIT_REF_NAME'] : ENV['CI_COMMIT_REF_SLUG'], - 'TRIGGERED_USER' => ENV['TRIGGERED_USER'] || ENV['GITLAB_USER_NAME'], - 'TRIGGER_SOURCE' => ENV['CI_JOB_URL'], - 'TOP_UPSTREAM_SOURCE_PROJECT' => ENV['CI_PROJECT_PATH'], - 'TOP_UPSTREAM_SOURCE_JOB' => ENV['CI_JOB_URL'], - 'TOP_UPSTREAM_SOURCE_SHA' => ENV['CI_COMMIT_SHA'] + "GITLAB_REF_SLUG" => ENV["CI_COMMIT_TAG"] ? ENV["CI_COMMIT_REF_NAME"] : ENV["CI_COMMIT_REF_SLUG"], + "TRIGGERED_USER" => ENV["TRIGGERED_USER"] || ENV["GITLAB_USER_NAME"], + "TRIGGER_SOURCE" => ENV["CI_JOB_URL"], + "TOP_UPSTREAM_SOURCE_PROJECT" => ENV["CI_PROJECT_PATH"], + "TOP_UPSTREAM_SOURCE_JOB" => ENV["CI_JOB_URL"], + "TOP_UPSTREAM_SOURCE_SHA" => ENV["CI_COMMIT_SHA"], } end @@ -89,27 +90,27 @@ module Trigger private def downstream_project_path - 'gitlab-org/omnibus-gitlab' + "gitlab-org/omnibus-gitlab" end def ref - ENV['OMNIBUS_BRANCH'] || 'master' + ENV["OMNIBUS_BRANCH"] || "master" end def trigger_token - ENV['BUILD_TRIGGER_TOKEN'] + ENV["BUILD_TRIGGER_TOKEN"] end def access_token - ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN'] + ENV["GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN"] end def extra_variables { - 'GITLAB_VERSION' => ENV['CI_COMMIT_SHA'], - 'ALTERNATIVE_SOURCES' => 'true', - 'ee' => Trigger.ee? ? 'true' : 'false', - 'QA_BRANCH' => ENV['QA_BRANCH'] || 'master' + "GITLAB_VERSION" => ENV["CI_COMMIT_SHA"], + "ALTERNATIVE_SOURCES" => "true", + "ee" => Trigger.ee? ? "true" : "false", + "QA_BRANCH" => ENV["QA_BRANCH"] || "master", } end end @@ -118,31 +119,31 @@ module Trigger private def downstream_project_path - ENV['CNG_PROJECT_PATH'] || 'gitlab-org/build/CNG-mirror' + ENV["CNG_PROJECT_PATH"] || "gitlab-org/build/CNG-mirror" end def ref - ENV['CNG_BRANCH'] || 'master' + ENV["CNG_BRANCH"] || "master" end def trigger_token - ENV['BUILD_TRIGGER_TOKEN'] + ENV["BUILD_TRIGGER_TOKEN"] end def access_token - ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN'] + ENV["GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN"] end def extra_variables - edition = Trigger.ee? ? 'EE' : 'CE' + edition = Trigger.ee? ? "EE" : "CE" { # Back-compatibility until https://gitlab.com/gitlab-org/build/CNG/merge_requests/189 is merged - "GITLAB_#{edition}_VERSION" => ENV['CI_COMMIT_REF_NAME'], - "GITLAB_VERSION" => ENV['CI_COMMIT_REF_NAME'], - "GITLAB_TAG" => ENV['CI_COMMIT_TAG'], - "GITLAB_ASSETS_TAG" => ENV['CI_COMMIT_REF_SLUG'], - "#{edition}_PIPELINE" => 'true' + "GITLAB_#{edition}_VERSION" => ENV["CI_COMMIT_REF_NAME"], + "GITLAB_VERSION" => ENV["CI_COMMIT_REF_NAME"], + "GITLAB_TAG" => ENV["CI_COMMIT_TAG"], + "GITLAB_ASSETS_TAG" => ENV["CI_COMMIT_REF_SLUG"], + "#{edition}_PIPELINE" => "true", } end @@ -150,7 +151,7 @@ module Trigger raw_version = super # if the version matches semver format, treat it as a tag and prepend `v` - if raw_version =~ Regexp.compile(/^\d+\.\d+\.\d+(-rc\d+)?(-ee)?$/) + if raw_version&.match?(Regexp.compile(/^\d+\.\d+\.\d+(-rc\d+)?(-ee)?$/)) "v#{raw_version}" else raw_version @@ -163,10 +164,10 @@ module Trigger Gitlab.private_token = access_token Gitlab.create_commit_comment( - ENV['CI_PROJECT_PATH'], - ENV['CI_COMMIT_SHA'], - "The [`#{ENV['CI_JOB_NAME']}`](#{ENV['CI_JOB_URL']}) job from pipeline #{ENV['CI_PIPELINE_URL']} triggered #{downstream_pipeline.web_url} downstream.") - + ENV["CI_PROJECT_PATH"], + ENV["CI_COMMIT_SHA"], + "The [`#{ENV["CI_JOB_NAME"]}`](#{ENV["CI_JOB_URL"]}) job from pipeline #{ENV["CI_PIPELINE_URL"]} triggered #{downstream_pipeline.web_url} downstream." + ) rescue Gitlab::Error::Error => error puts "Ignoring the following error: #{error}" end @@ -227,9 +228,9 @@ module Trigger end case ARGV[0] -when 'omnibus' +when "omnibus" Trigger::Omnibus.new.invoke!(post_comment: true).wait! -when 'cng' +when "cng" Trigger::CNG.new.invoke!.wait! else puts "Please provide a valid option: |