Commit c338cd34 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'pb-add-fields-to-job-type' into 'master'

Add needed fields to job type

See merge request gitlab-org/gitlab!57530
parents c511572b 78ccc6b6
......@@ -47,6 +47,22 @@ module Types
description: 'Short SHA1 ID of the commit.'
field :scheduling_type, GraphQL::STRING_TYPE, null: true,
description: 'Type of pipeline scheduling. Value is `dag` if the pipeline uses the `needs` keyword, and `stage` otherwise.'
field :commit_path, GraphQL::STRING_TYPE, null: true,
description: 'Path to the commit that triggered the job.'
field :ref_name, GraphQL::STRING_TYPE, null: true,
description: 'Ref name of the job.'
field :ref_path, GraphQL::STRING_TYPE, null: true,
description: 'Path to the ref.'
field :playable, GraphQL::BOOLEAN_TYPE, null: false, method: :playable?,
description: 'Indicates the job can be played.'
field :retryable, GraphQL::BOOLEAN_TYPE, null: false, method: :retryable?,
description: 'Indicates the job can be retried.'
field :cancelable, GraphQL::BOOLEAN_TYPE, null: false, method: :cancelable?,
description: 'Indicates the job can be canceled.'
field :active, GraphQL::BOOLEAN_TYPE, null: false, method: :active?,
description: 'Indicates the job is active.'
field :coverage, GraphQL::FLOAT_TYPE, null: true,
description: 'Coverage level of the job.'
def pipeline
Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, object.pipeline_id).find
......@@ -85,6 +101,22 @@ module Types
id = object.id
Gitlab::GlobalId.build(model_name: model_name, id: id)
end
def commit_path
::Gitlab::Routing.url_helpers.project_commit_path(object.project, object.sha)
end
def ref_name
object&.ref
end
def ref_path
::Gitlab::Routing.url_helpers.project_commits_path(object.project, ref_name)
end
def coverage
object&.coverage
end
end
end
end
---
title: Add more fields to the job type
merge_request: 57530
author:
type: added
......@@ -1210,8 +1210,12 @@ An edge in a connection.
| Field | Type | Description |
| ----- | ---- | ----------- |
| `active` | [`Boolean!`](#boolean) | Indicates the job is active. |
| `allowFailure` | [`Boolean!`](#boolean) | Whether this job is allowed to fail. |
| `artifacts` | [`CiJobArtifactConnection`](#cijobartifactconnection) | Artifacts generated by the job. |
| `cancelable` | [`Boolean!`](#boolean) | Indicates the job can be canceled. |
| `commitPath` | [`String`](#string) | Path to the commit that triggered the job. |
| `coverage` | [`Float`](#float) | Coverage level of the job. |
| `createdAt` | [`Time!`](#time) | When the job was created. |
| `detailedStatus` | [`DetailedStatus`](#detailedstatus) | Detailed status of the job. |
| `duration` | [`Int`](#int) | Duration of the job in seconds. |
......@@ -1220,7 +1224,11 @@ An edge in a connection.
| `name` | [`String`](#string) | Name of the job. |
| `needs` | [`CiBuildNeedConnection`](#cibuildneedconnection) | References to builds that must complete before the jobs run. |
| `pipeline` | [`Pipeline`](#pipeline) | Pipeline the job belongs to. |
| `playable` | [`Boolean!`](#boolean) | Indicates the job can be played. |
| `queuedAt` | [`Time`](#time) | When the job was enqueued and marked as pending. |
| `refName` | [`String`](#string) | Ref name of the job. |
| `refPath` | [`String`](#string) | Path to the ref. |
| `retryable` | [`Boolean!`](#boolean) | Indicates the job can be retried. |
| `scheduledAt` | [`Time`](#time) | Schedule for the build. |
| `schedulingType` | [`String`](#string) | Type of pipeline scheduling. Value is `dag` if the pipeline uses the `needs` keyword, and `stage` otherwise. |
| `shortSha` | [`String!`](#string) | Short SHA1 ID of the commit. |
......
......@@ -8,8 +8,12 @@ RSpec.describe Types::Ci::JobType do
it 'exposes the expected fields' do
expected_fields = %i[
active
allow_failure
artifacts
cancelable
commitPath
coverage
created_at
detailedStatus
duration
......@@ -18,7 +22,11 @@ RSpec.describe Types::Ci::JobType do
name
needs
pipeline
playable
queued_at
refName
refPath
retryable
scheduledAt
schedulingType
shortSha
......
......@@ -9,9 +9,10 @@ RSpec.describe 'Query.project.pipeline.stages.groups' do
let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) }
let(:group_graphql_data) { graphql_data_at(:project, :pipeline, :stages, :nodes, 0, :groups, :nodes) }
let_it_be(:job_a) { create(:commit_status, pipeline: pipeline, name: 'rspec 0 2') }
let_it_be(:job_b) { create(:ci_build, pipeline: pipeline, name: 'rspec 0 1') }
let_it_be(:job_c) { create(:ci_bridge, pipeline: pipeline, name: 'spinach 0 1') }
let_it_be(:ref) { 'master' }
let_it_be(:job_a) { create(:commit_status, pipeline: pipeline, name: 'rspec 0 2', ref: ref) }
let_it_be(:job_b) { create(:ci_build, pipeline: pipeline, name: 'rspec 0 1', ref: ref) }
let_it_be(:job_c) { create(:ci_bridge, pipeline: pipeline, name: 'spinach 0 1', ref: ref) }
let(:params) { {} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment