diff options
Diffstat (limited to 'app/presenters/ci/build_presenter.rb')
-rw-r--r-- | app/presenters/ci/build_presenter.rb | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/app/presenters/ci/build_presenter.rb b/app/presenters/ci/build_presenter.rb index 6b52c91749f..5e3829693d1 100644 --- a/app/presenters/ci/build_presenter.rb +++ b/app/presenters/ci/build_presenter.rb @@ -34,14 +34,31 @@ module Ci end def config_artifacts - list = [] + [].tap do |list| + next unless options[:artifacts] - options.dig(:artifacts).try do |artifacts| - list << config_artifacts_reports(artifacts.delete(:reports)) if artifacts.dig(:reports) - list << config_artifacts_archive(artifacts) if artifacts.dig(:paths) - end + options[:artifacts].except(:reports).try do |archive| + ::Gitlab::Ci::Config::Entry::Artifacts.new(archive).present_for_runner.tap do |runner_config| + unless ::Gitlab::Ci::Config::Entry::ArtifactsForRunner.new(runner_config).valid? + raise ArgumentError, 'General artifact config for runner is not valid' + end + + list << runner_config + end + end + + options[:artifacts].dig(:reports).try do |reports| + ::Gitlab::Ci::Config::Entry::Reports.new(reports).present_for_runner.tap do |runner_configs| + list << runner_configs.map do |runner_config| + unless ::Gitlab::Ci::Config::Entry::ArtifactsForRunner.new(runner_config).valid? + raise ArgumentError, 'Report-type artifact config for runner is not valid' + end - list.flatten + runner_config + end + end + end + end.flatten end private @@ -53,21 +70,5 @@ module Ci def detailed_status @detailed_status ||= subject.detailed_status(user) end - - def config_artifacts_archive(artifacts) - artifacts.merge(type: :archive, format: :zip) - end - - def config_artifacts_reports(reports) - list = [] - - list << config_artifacts_reports_junit(reports.dig(:junit)) if reports.dig(:junit) - - list - end - - def config_artifacts_reports_junit(junit) - { name: 'junit.xml', paths: junit, type: :junit, format: :gzip, when: :always } - end end end |