diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2019-09-10 18:26:28 +0300 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2019-09-10 18:26:28 +0300 |
commit | 4d8d7773f5578c32bf239b444bd2bc563ca321e7 (patch) | |
tree | 9576f044c32a9eb73f0bd71b63db991b098b8100 | |
parent | 6def5bd66b04f887dd0d24ae4030ec86195ff7cb (diff) |
Expose pipeline test reports via API
-rw-r--r-- | lib/api/entities/test_suite.rb | 27 | ||||
-rw-r--r-- | lib/api/pipelines.rb | 13 |
2 files changed, 40 insertions, 0 deletions
diff --git a/lib/api/entities/test_suite.rb b/lib/api/entities/test_suite.rb new file mode 100644 index 00000000000..cb664d72a77 --- /dev/null +++ b/lib/api/entities/test_suite.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module API + module Entities + class TestCase < Grape::Entity + expose :classname + expose :execution_time + expose :file + expose :key + expose :name + expose :stack_trace + expose :status + expose :system_output + end + + class TestSuite < Grape::Entity + expose :name + expose :total_time + + Gitlab::Ci::Reports::TestCase::STATUS_TYPES.each do |status| + expose status, using: TestCase do |test_suite| + test_suite.test_cases[status]&.values || [] + end + end + end + end +end diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 9e888368e7b..38eab13d073 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -95,6 +95,19 @@ module API present pipeline.variables, with: Entities::Variable end + desc 'Gets the test reports from all jobs of a given pipeline' do + # TODO: detail 'This feature was introduced in GitLab 42' + success Entities::TestSuite + end + params do + requires :pipeline_id, type: Integer, desc: 'The pipeline ID' + end + get ':id/pipelines/:pipeline_id/test_reports' do + authorize! :read_pipeline_variable, pipeline + + present pipeline.test_reports.test_suites.values, with: Entities::TestSuite + end + desc 'Deletes a pipeline' do detail 'This feature was introduced in GitLab 11.6' http_codes [[204, 'Pipeline was deleted'], [403, 'Forbidden']] |