Welcome to mirror list, hosted at ThFree Co, Russian Federation.

job_type.rb « ci « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f8bf1732e631a1da5d15024ccc4e8b3c56c1318f (plain)
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
# frozen_string_literal: true

module Types
  module Ci
    class JobType < BaseObject
      graphql_name 'CiJob'
      authorize :read_commit_status

      field :pipeline, Types::Ci::PipelineType, null: true,
            description: 'Pipeline the job belongs to'
      field :name, GraphQL::STRING_TYPE, null: true,
            description: 'Name of the job'
      field :needs, BuildNeedType.connection_type, null: true,
            description: 'References to builds that must complete before the jobs run'
      field :detailed_status, Types::Ci::DetailedStatusType, null: true,
            description: 'Detailed status of the job'
      field :scheduled_at, Types::TimeType, null: true,
            description: 'Schedule for the build'
      field :artifacts, Types::Ci::JobArtifactType.connection_type, null: true,
            description: 'Artifacts generated by the job'

      def pipeline
        Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, object.pipeline_id).find
      end

      def detailed_status
        object.detailed_status(context[:current_user])
      end

      def artifacts
        if object.is_a?(::Ci::Build)
          object.job_artifacts
        end
      end
    end
  end
end