Sha256: dbc4d8c308ac29a5f092861acd85b6e5f32c3426d26eb4a910a3e2474708d848

Contents?: true

Size: 1.58 KB

Versions: 99

Compression:

Stored size: 1.58 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)
    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}.
      COMMENT
    )
  rescue Gitlab::Error::Error => error
    puts "Ignoring the following error: #{error}"
  end
end

status = ARGV.shift.to_s.strip

abort "Please provide a status!" if status == ''

CommitComment.post!(status.to_sym)

Version data entries

99 entries across 99 versions & 1 rubygems

Version Path
gitlab-qa-7.6.0 bin/notify_upstream_commit
gitlab-qa-7.5.0 bin/notify_upstream_commit
gitlab-qa-7.4.0 bin/notify_upstream_commit
gitlab-qa-7.3.1 bin/notify_upstream_commit
gitlab-qa-7.3.0 bin/notify_upstream_commit
gitlab-qa-7.2.1 bin/notify_upstream_commit
gitlab-qa-7.2.0 bin/notify_upstream_commit
gitlab-qa-7.1.1 bin/notify_upstream_commit
gitlab-qa-7.1.0 bin/notify_upstream_commit
gitlab-qa-7.0.5 bin/notify_upstream_commit
gitlab-qa-7.0.4 bin/notify_upstream_commit
gitlab-qa-7.0.3 bin/notify_upstream_commit
gitlab-qa-7.0.2 bin/notify_upstream_commit
gitlab-qa-7.0.1 bin/notify_upstream_commit
gitlab-qa-7.0.0 bin/notify_upstream_commit
gitlab-qa-6.23.0 bin/notify_upstream_commit
gitlab-qa-6.22.1 bin/notify_upstream_commit
gitlab-qa-6.22.0 bin/notify_upstream_commit
gitlab-qa-6.21.4 bin/notify_upstream_commit
gitlab-qa-6.21.3 bin/notify_upstream_commit