debian-mirror-gitlab/lib/api/entities/ci/job_basic.rb

44 lines
2.1 KiB
Ruby
Raw Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
module API
module Entities
module Ci
class JobBasic < Grape::Entity
2023-01-13 00:05:48 +05:30
expose :id, documentation: { type: 'integer', example: 1 }
expose :status, documentation: { type: 'string', example: 'waiting_for_resource' }
expose :stage, documentation: { type: 'string', example: 'deploy' }
expose :name, documentation: { type: 'string', example: 'deploy_to_production' }
expose :ref, documentation: { type: 'string', example: 'main' }
expose :tag, documentation: { type: 'boolean' }
expose :coverage, documentation: { type: 'number', format: 'float', example: 98.29 }
expose :allow_failure, documentation: { type: 'boolean' }
expose :created_at, documentation: { type: 'dateTime', example: '2015-12-24T15:51:21.880Z' }
expose :started_at, documentation: { type: 'dateTime', example: '2015-12-24T17:54:30.733Z' }
expose :finished_at, documentation: { type: 'dateTime', example: '2015-12-24T17:54:31.198Z' }
2021-06-08 01:23:25 +05:30
expose :duration,
2023-01-13 00:05:48 +05:30
documentation: { type: 'number', format: 'float', desc: 'Time spent running', example: 0.465 }
2021-06-08 01:23:25 +05:30
expose :queued_duration,
2023-01-13 00:05:48 +05:30
documentation: { type: 'number', format: 'float', desc: 'Time spent enqueued', example: 0.123 }
2020-10-24 23:57:45 +05:30
expose :user, with: ::API::Entities::User
expose :commit, with: ::API::Entities::Commit
expose :pipeline, with: ::API::Entities::Ci::PipelineBasic
2023-01-13 00:05:48 +05:30
expose :failure_reason,
documentation: { type: 'string', example: 'script_failure' }, if: -> (job) { job.failed? }
2020-10-24 23:57:45 +05:30
2023-01-13 00:05:48 +05:30
expose(
:web_url,
documentation: { type: 'string', example: 'https://example.com/foo/bar/-/jobs/1' }
) do |job, _options|
2020-10-24 23:57:45 +05:30
Gitlab::Routing.url_helpers.project_job_url(job.project, job)
end
2022-10-11 01:57:18 +05:30
expose :project do
2023-01-13 00:05:48 +05:30
expose :ci_job_token_scope_enabled, documentation: { type: 'string', example: false } do |job|
2022-11-25 23:54:43 +05:30
job.project.ci_outbound_job_token_scope_enabled?
2022-10-11 01:57:18 +05:30
end
end
2020-10-24 23:57:45 +05:30
end
end
end
end