diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 09:08:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 09:08:40 +0300 |
commit | 116d4e56e83a1f408afe710ce070e699ba206475 (patch) | |
tree | cc62d3820d9bfa199061edfdef3a2f4bda140507 /lib/gitlab/ci | |
parent | dddde902acfa6acfb11583c61faa67cc7c8d11b6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/ci')
-rw-r--r-- | lib/gitlab/ci/parsers/test/junit.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/ci/reports/test_case.rb | 17 |
2 files changed, 20 insertions, 6 deletions
diff --git a/lib/gitlab/ci/parsers/test/junit.rb b/lib/gitlab/ci/parsers/test/junit.rb index 0ce901fa5aa..c3e4c88d077 100644 --- a/lib/gitlab/ci/parsers/test/junit.rb +++ b/lib/gitlab/ci/parsers/test/junit.rb @@ -8,11 +8,11 @@ module Gitlab JunitParserError = Class.new(Gitlab::Ci::Parsers::ParserError) ATTACHMENT_TAG_REGEX = /\[\[ATTACHMENT\|(?<path>.+?)\]\]/.freeze - def parse!(xml_data, test_suite) + def parse!(xml_data, test_suite, **args) root = Hash.from_xml(xml_data) all_cases(root) do |test_case| - test_case = create_test_case(test_case) + test_case = create_test_case(test_case, args) test_suite.add_test_case(test_case) end rescue Nokogiri::XML::SyntaxError @@ -46,7 +46,7 @@ module Gitlab [testcase].flatten.compact.map(&blk) end - def create_test_case(data) + def create_test_case(data, args) if data['failure'] status = ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED system_output = data['failure'] @@ -66,7 +66,8 @@ module Gitlab execution_time: data['time'], status: status, system_output: system_output, - attachment: attachment + attachment: attachment, + job: args.fetch(:job) ) end diff --git a/lib/gitlab/ci/reports/test_case.rb b/lib/gitlab/ci/reports/test_case.rb index 55856f64533..d95941059ff 100644 --- a/lib/gitlab/ci/reports/test_case.rb +++ b/lib/gitlab/ci/reports/test_case.rb @@ -10,9 +10,10 @@ module Gitlab STATUS_ERROR = 'error' STATUS_TYPES = [STATUS_SUCCESS, STATUS_FAILED, STATUS_SKIPPED, STATUS_ERROR].freeze - attr_reader :name, :classname, :execution_time, :status, :file, :system_output, :stack_trace, :key, :attachment + attr_reader :name, :classname, :execution_time, :status, :file, :system_output, :stack_trace, :key, :attachment, :job - def initialize(name:, classname:, execution_time:, status:, file: nil, system_output: nil, stack_trace: nil, attachment: nil) + # rubocop: disable Metrics/ParameterLists + def initialize(name:, classname:, execution_time:, status:, file: nil, system_output: nil, stack_trace: nil, attachment: nil, job: nil) @name = name @classname = classname @file = file @@ -22,12 +23,24 @@ module Gitlab @stack_trace = stack_trace @key = sanitize_key_name("#{classname}_#{name}") @attachment = attachment + @job = job end + # rubocop: enable Metrics/ParameterLists def has_attachment? attachment.present? end + def attachment_url + return unless has_attachment? + + Rails.application.routes.url_helpers.file_project_job_artifacts_path( + job.project, + job.id, + attachment + ) + end + private def sanitize_key_name(key) |