Sha256: 495bba09542dde7f400323170b165391c12a80f0dbd3afee3a173fa03ef7be9a

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Gitlab
  module QA
    module Report
      class ReportAsIssue
        def initialize(token:, input_files:, project: nil)
          @gitlab = GitlabIssueClient.new(token: token, project: project)
          @files = Array(input_files)
          @project = project
        end

        def invoke!
          validate_input!

          run!
        end

        private

        attr_reader :gitlab, :files, :project

        def run!
          raise NotImplementedError
        end

        def validate_input!
          assert_project!
          assert_input_files!(files)
          gitlab.assert_user_permission!
        end

        def assert_project!
          return if project

          abort "Please provide a valid project ID or path with the `-p/--project` option!"
        end

        def assert_input_files!(files)
          return if Dir.glob(files).any?

          abort "Please provide valid JUnit report files. No files were found matching `#{files.join(',')}`"
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gitlab-qa-6.7.0 lib/gitlab/qa/report/report_as_issue.rb
gitlab-qa-6.6.0 lib/gitlab/qa/report/report_as_issue.rb
gitlab-qa-6.5.0 lib/gitlab/qa/report/report_as_issue.rb
gitlab-qa-6.4.1 lib/gitlab/qa/report/report_as_issue.rb
gitlab-qa-6.4.0 lib/gitlab/qa/report/report_as_issue.rb
gitlab-qa-6.3.0 lib/gitlab/qa/report/report_as_issue.rb