Sha256: 8834c1c19853f4b676fbe87bf06318292696b2d57416d68a460ed94f6fbceb02
Contents?: true
Size: 1.86 KB
Versions: 15
Compression:
Stored size: 1.86 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'gitlab' # Configure credentials to be used with gitlab gem Gitlab.configure do |config| config.endpoint = 'https://gitlab.com/api/v4' config.private_token = ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN'] end class CommitComment def self.post!(status, report_file_name) unless ENV['TOP_UPSTREAM_SOURCE_SHA'] puts "The 'TOP_UPSTREAM_SOURCE_SHA' environment variable is missing, cannot post a comment on a missing upstream commit." return end top_upstream_source_sha = ENV['TOP_UPSTREAM_SOURCE_SHA'] unless ENV['TOP_UPSTREAM_SOURCE_PROJECT'] puts "The 'TOP_UPSTREAM_SOURCE_PROJECT' environment variable is missing, cannot post a comment on the upstream #{top_upstream_source_sha} commit." return end top_upstream_source_project = ENV['TOP_UPSTREAM_SOURCE_PROJECT'] status_with_icon = case status when :success "passed. :white_check_mark:" when :failure "failed! :boom:" end # The HTML report can't be opened as a web page so we're forced to # download it. See https://gitlab.com/gitlab-org/gitlab/issues/25192 Gitlab.create_commit_comment( top_upstream_source_project, top_upstream_source_sha, <<~COMMENT The [`gitlab-qa` downstream pipeline](#{ENV['CI_PIPELINE_URL']}) #{status_with_icon}. You can download a report of the test results: [`#{report_file_name}`](#{ENV['CI_JOB_URL']}/artifacts/raw/#{report_file_name}) COMMENT ) rescue Gitlab::Error::Error => error puts "Ignoring the following error: #{error}" end end status = ARGV.shift.to_s.strip report_file_name = ARGV.shift.to_s.strip abort "Please provide a status!" if status == '' abort "Please provide a file name for the report!" if report_file_name == '' CommitComment.post!(status.to_sym, report_file_name)
Version data entries
15 entries across 15 versions & 1 rubygems