summaryrefslogtreecommitdiff
path: root/scripts/trigger-build
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/trigger-build')
-rwxr-xr-xscripts/trigger-build41
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)