Commit 78ccc6b6 authored by pburdette's avatar pburdette

Add fields to job type

Add missing fields to
the job type.
parent 46ef07c2
...@@ -47,6 +47,22 @@ module Types ...@@ -47,6 +47,22 @@ module Types
description: 'Short SHA1 ID of the commit.' description: 'Short SHA1 ID of the commit.'
field :scheduling_type, GraphQL::STRING_TYPE, null: true, 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.' 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 def pipeline
Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, object.pipeline_id).find Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, object.pipeline_id).find
...@@ -85,6 +101,22 @@ module Types ...@@ -85,6 +101,22 @@ module Types
id = object.id id = object.id
Gitlab::GlobalId.build(model_name: model_name, id: id) Gitlab::GlobalId.build(model_name: model_name, id: id)
end 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 end
end end
---
title: Add more fields to the job type
merge_request: 57530
author:
type: added
...@@ -1208,8 +1208,12 @@ An edge in a connection. ...@@ -1208,8 +1208,12 @@ An edge in a connection.
| Field | Type | Description | | Field | Type | Description |
| ----- | ---- | ----------- | | ----- | ---- | ----------- |
| `active` | [`Boolean!`](#boolean) | Indicates the job is active. |
| `allowFailure` | [`Boolean!`](#boolean) | Whether this job is allowed to fail. | | `allowFailure` | [`Boolean!`](#boolean) | Whether this job is allowed to fail. |
| `artifacts` | [`CiJobArtifactConnection`](#cijobartifactconnection) | Artifacts generated by the job. | | `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. | | `createdAt` | [`Time!`](#time) | When the job was created. |
| `detailedStatus` | [`DetailedStatus`](#detailedstatus) | Detailed status of the job. | | `detailedStatus` | [`DetailedStatus`](#detailedstatus) | Detailed status of the job. |
| `duration` | [`Int`](#int) | Duration of the job in seconds. | | `duration` | [`Int`](#int) | Duration of the job in seconds. |
...@@ -1218,7 +1222,11 @@ An edge in a connection. ...@@ -1218,7 +1222,11 @@ An edge in a connection.
| `name` | [`String`](#string) | Name of the job. | | `name` | [`String`](#string) | Name of the job. |
| `needs` | [`CiBuildNeedConnection`](#cibuildneedconnection) | References to builds that must complete before the jobs run. | | `needs` | [`CiBuildNeedConnection`](#cibuildneedconnection) | References to builds that must complete before the jobs run. |
| `pipeline` | [`Pipeline`](#pipeline) | Pipeline the job belongs to. | | `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. | | `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. | | `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. | | `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. | | `shortSha` | [`String!`](#string) | Short SHA1 ID of the commit. |
......
...@@ -8,8 +8,12 @@ RSpec.describe Types::Ci::JobType do ...@@ -8,8 +8,12 @@ RSpec.describe Types::Ci::JobType do
it 'exposes the expected fields' do it 'exposes the expected fields' do
expected_fields = %i[ expected_fields = %i[
active
allow_failure allow_failure
artifacts artifacts
cancelable
commitPath
coverage
created_at created_at
detailedStatus detailedStatus
duration duration
...@@ -18,7 +22,11 @@ RSpec.describe Types::Ci::JobType do ...@@ -18,7 +22,11 @@ RSpec.describe Types::Ci::JobType do
name name
needs needs
pipeline pipeline
playable
queued_at queued_at
refName
refPath
retryable
scheduledAt scheduledAt
schedulingType schedulingType
shortSha shortSha
......
...@@ -9,9 +9,10 @@ RSpec.describe 'Query.project.pipeline.stages.groups' do ...@@ -9,9 +9,10 @@ RSpec.describe 'Query.project.pipeline.stages.groups' do
let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) } 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(: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(:ref) { 'master' }
let_it_be(:job_b) { create(:ci_build, pipeline: pipeline, name: 'rspec 0 1') } let_it_be(:job_a) { create(:commit_status, pipeline: pipeline, name: 'rspec 0 2', ref: ref) }
let_it_be(:job_c) { create(:ci_bridge, pipeline: pipeline, name: 'spinach 0 1') } 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) { {} } 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