diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /scripts/trigger-build | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) | |
download | gitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'scripts/trigger-build')
-rwxr-xr-x | scripts/trigger-build | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/scripts/trigger-build b/scripts/trigger-build index 0d8a46bdd2d..23c9ebbe294 100755 --- a/scripts/trigger-build +++ b/scripts/trigger-build @@ -255,7 +255,7 @@ module Trigger end def ref - ENV['DOCS_BRANCH'] || 'master' + ENV['DOCS_BRANCH'] || 'main' end # `gitlab-org/gitlab-docs` pipeline trigger "Triggered from gitlab-org/gitlab 'review-docs-deploy' job" @@ -297,10 +297,43 @@ module Trigger end class DatabaseTesting < Base + IDENTIFIABLE_NOTE_TAG = 'gitlab-org/database-team/gitlab-com-database-testing:identifiable-note' + def self.access_token ENV['GITLABCOM_DATABASE_TESTING_ACCESS_TOKEN'] end + def invoke!(post_comment: false, downstream_job_name: nil) + pipeline = super + gitlab = gitlab_client(:upstream) + project_path = base_variables['TOP_UPSTREAM_SOURCE_PROJECT'] + merge_request_id = base_variables['TOP_UPSTREAM_MERGE_REQUEST_IID'] + comment = "<!-- #{IDENTIFIABLE_NOTE_TAG} --> \nStarted database testing [pipeline](https://ops.gitlab.net/#{downstream_project_path}/-/pipelines/#{pipeline.id}) " \ + "(limited access). This comment will be updated once the pipeline has finished running." + + # Look for a note to update + db_testing_notes = gitlab.merge_request_notes(project_path, merge_request_id).auto_paginate.select do |note| + note.body.include?(IDENTIFIABLE_NOTE_TAG) + end + + note = db_testing_notes.max_by { |note| Time.parse(note.created_at) } + + if note && note.type != 'DiscussionNote' + # The latest note has not led to a discussion. Update it. + gitlab.edit_merge_request_note(project_path, merge_request_id, note.id, comment) + + puts "Updated comment:\n" + else + # This is the first note or the latest note has been discussed on the MR. + # Don't update, create new note instead. + note = gitlab.create_merge_request_note(project_path, merge_request_id, comment) + + puts "Posted comment to:\n" + end + + puts "https://gitlab.com/#{project_path}/-/merge_requests/#{merge_request_id}#note_#{note.id}" + end + private def gitlab_client(type) @@ -356,6 +389,8 @@ module Trigger INTERVAL = 60 # seconds MAX_DURATION = 3600 * 3 # 3 hours + attr_reader :id + def self.unscoped_class_name name.split('::').last end @@ -384,7 +419,7 @@ module Trigger raise "#{self.class.unscoped_class_name} did not succeed!" end - STDOUT.flush + $stdout.flush end raise "#{self.class.unscoped_class_name} timed out after waiting for #{duration} minutes!" @@ -405,7 +440,7 @@ module Trigger private - attr_reader :project, :id, :gitlab_client, :start_time + attr_reader :project, :gitlab_client, :start_time end Job = Class.new(Pipeline) |