diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-10 21:09:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-10 21:09:15 +0300 |
commit | f6905d2ed293ccde386ba2798e7a623c228e8f51 (patch) | |
tree | 83e7defc9e9ec94462c3bc3d86e4ca0cbc4b7c21 /scripts | |
parent | f2f748c08166ef350aa4183242c3611f6617f651 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build_assets_image | 2 | ||||
-rwxr-xr-x | scripts/trigger-build | 26 |
2 files changed, 15 insertions, 13 deletions
diff --git a/scripts/build_assets_image b/scripts/build_assets_image index 9eb1ccd5515..12beddfa184 100755 --- a/scripts/build_assets_image +++ b/scripts/build_assets_image @@ -1,7 +1,7 @@ # Exit early if we don't want to build the image if [[ "${BUILD_ASSETS_IMAGE}" != "true" ]] then - exit 0 + exit 0 fi # Generate the image name based on the project this is being run in diff --git a/scripts/trigger-build b/scripts/trigger-build index c7b45480bf3..b8bea95a069 100755 --- a/scripts/trigger-build +++ b/scripts/trigger-build @@ -16,6 +16,10 @@ module Trigger %w[gitlab gitlab-ee].include?(ENV['CI_PROJECT_NAME']) end + def self.security? + %r{\Agitlab-org/security(\z|/)}.match?(ENV['CI_PROJECT_NAMESPACE']) + end + def self.non_empty_variable_value(variable) variable_value = ENV[variable] @@ -26,6 +30,9 @@ module Trigger class Base def invoke!(post_comment: false, downstream_job_name: nil) + # gitlab-bot's token "GitLab multi-project pipeline polling" + Gitlab.private_token = access_token + pipeline_variables = variables puts "Triggering downstream pipeline on #{downstream_project_path}" @@ -40,7 +47,7 @@ module Trigger puts "Triggered downstream pipeline: #{pipeline.web_url}\n" puts "Waiting for downstream pipeline status" - Trigger::CommitComment.post!(pipeline, access_token) if post_comment + Trigger::CommitComment.post!(pipeline) if post_comment downstream_job = if downstream_job_name Gitlab.pipeline_jobs(downstream_project_path, pipeline.id).auto_paginate.find do |potential_job| @@ -49,9 +56,9 @@ module Trigger end if downstream_job - Trigger::Job.new(downstream_project_path, downstream_job.id, access_token) + Trigger::Job.new(downstream_project_path, downstream_job.id) else - Trigger::Pipeline.new(downstream_project_path, pipeline.id, access_token) + Trigger::Pipeline.new(downstream_project_path, pipeline.id) end end @@ -140,6 +147,7 @@ module Trigger { 'GITLAB_VERSION' => Trigger.non_empty_variable_value('CI_MERGE_REQUEST_SOURCE_BRANCH_SHA') || ENV['CI_COMMIT_SHA'], 'ALTERNATIVE_SOURCES' => 'true', + 'SECURITY_SOURCES' => Trigger.security? ? 'true' : 'false', 'ee' => Trigger.ee? ? 'true' : 'false', 'QA_BRANCH' => ENV['QA_BRANCH'] || 'master' } @@ -197,9 +205,7 @@ module Trigger end class CommitComment - def self.post!(downstream_pipeline, access_token) - Gitlab.private_token = access_token - + def self.post!(downstream_pipeline) Gitlab.create_commit_comment( ENV['CI_PROJECT_PATH'], Trigger.non_empty_variable_value('CI_MERGE_REQUEST_SOURCE_BRANCH_SHA') || ENV['CI_COMMIT_SHA'], @@ -214,7 +220,7 @@ module Trigger INTERVAL = 60 # seconds MAX_DURATION = 3600 * 3 # 3 hours - attr_reader :project, :id, :api_token + attr_reader :project, :id def self.unscoped_class_name name.split('::').last @@ -224,14 +230,10 @@ module Trigger unscoped_class_name.downcase end - def initialize(project, id, api_token) + def initialize(project, id) @project = project @id = id - @api_token = api_token @start = Time.now.to_i - - # gitlab-bot's token "GitLab multi-project pipeline polling" - Gitlab.private_token = api_token end def wait! |