File: job_basic.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (44 lines) | stat: -rw-r--r-- 2,189 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true

module API
  module Entities
    module Ci
      class JobBasic < Grape::Entity
        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' }
        expose :erased_at, documentation: { type: 'dateTime', example: '2015-12-24T18:00:29.728Z' }
        expose :duration,
          documentation: { type: 'number', format: 'float', desc: 'Time spent running', example: 0.465 }
        expose :queued_duration,
          documentation: { type: 'number', format: 'float', desc: 'Time spent enqueued', example: 0.123 }
        expose :user, with: ::API::Entities::User
        expose :commit, with: ::API::Entities::Commit
        expose :pipeline, with: ::API::Entities::Ci::PipelineBasic
        expose :failure_reason,
          documentation: { type: 'string', example: 'script_failure' }, if: ->(job) { job.failed? }

        expose(
          :web_url,
          documentation: { type: 'string', example: 'https://example.com/foo/bar/-/jobs/1' }
        ) do |job, _options|
          Gitlab::Routing.url_helpers.project_job_url(job.project, job)
        end

        expose :project do
          expose :ci_job_token_scope_enabled, documentation: { type: 'string', example: false } do |job|
            job.project.ci_outbound_job_token_scope_enabled?
          end
        end
      end
    end
  end
end