Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
914bdb7b
Commit
914bdb7b
authored
Nov 11, 2020
by
Tiger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pipeline to CI job GraphQL type
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/47347
parent
023b7230
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
3 deletions
+58
-3
app/graphql/types/ci/job_type.rb
app/graphql/types/ci/job_type.rb
+3
-0
changelogs/unreleased/267168-add-pipeline-to-ci-job-type.yml
changelogs/unreleased/267168-add-pipeline-to-ci-job-type.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+5
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+18
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+1
-0
spec/graphql/types/ci/job_type_spec.rb
spec/graphql/types/ci/job_type_spec.rb
+1
-0
spec/requests/api/graphql/ci/jobs_spec.rb
spec/requests/api/graphql/ci/jobs_spec.rb
+25
-3
No files found.
app/graphql/types/ci/job_type.rb
View file @
914bdb7b
...
@@ -6,6 +6,9 @@ module Types
...
@@ -6,6 +6,9 @@ module Types
class
JobType
<
BaseObject
class
JobType
<
BaseObject
graphql_name
'CiJob'
graphql_name
'CiJob'
field
:pipeline
,
Types
::
Ci
::
PipelineType
,
null:
false
,
description:
'Pipeline the job belongs to'
,
resolve:
->
(
build
,
_
,
_
)
{
Gitlab
::
Graphql
::
Loaders
::
BatchModelLoader
.
new
(
::
Ci
::
Pipeline
,
build
.
pipeline_id
).
find
}
field
:name
,
GraphQL
::
STRING_TYPE
,
null:
true
,
field
:name
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Name of the job'
description:
'Name of the job'
field
:needs
,
JobType
.
connection_type
,
null:
true
,
field
:needs
,
JobType
.
connection_type
,
null:
true
,
...
...
changelogs/unreleased/267168-add-pipeline-to-ci-job-type.yml
0 → 100644
View file @
914bdb7b
---
title
:
Add pipeline to CI job GraphQL type
merge_request
:
47347
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
914bdb7b
...
@@ -2325,6 +2325,11 @@ type CiJob {
...
@@ -2325,6 +2325,11 @@ type CiJob {
last
:
Int
last
:
Int
):
CiJobConnection
):
CiJobConnection
"""
Pipeline
the
job
belongs
to
"""
pipeline
:
Pipeline
!
"""
"""
Schedule
for
the
build
Schedule
for
the
build
"""
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
914bdb7b
...
@@ -6240,6 +6240,24 @@
...
@@ -6240,6 +6240,24 @@
"isDeprecated": false,
"isDeprecated": false,
"deprecationReason": null
"deprecationReason": null
},
},
{
"name": "pipeline",
"description": "Pipeline the job belongs to",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Pipeline",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
{
"name": "scheduledAt",
"name": "scheduledAt",
"description": "Schedule for the build",
"description": "Schedule for the build",
doc/api/graphql/reference/index.md
View file @
914bdb7b
...
@@ -379,6 +379,7 @@ Represents the total number of issues and their weights for a particular day.
...
@@ -379,6 +379,7 @@ Represents the total number of issues and their weights for a particular day.
|
`detailedStatus`
| DetailedStatus | Detailed status of the job |
|
`detailedStatus`
| DetailedStatus | Detailed status of the job |
|
`name`
| String | Name of the job |
|
`name`
| String | Name of the job |
|
`needs`
| CiJobConnection | Builds that must complete before the jobs run |
|
`needs`
| CiJobConnection | Builds that must complete before the jobs run |
|
`pipeline`
| Pipeline! | Pipeline the job belongs to |
|
`scheduledAt`
| Time | Schedule for the build |
|
`scheduledAt`
| Time | Schedule for the build |
### CiStage
### CiStage
...
...
spec/graphql/types/ci/job_type_spec.rb
View file @
914bdb7b
...
@@ -7,6 +7,7 @@ RSpec.describe Types::Ci::JobType do
...
@@ -7,6 +7,7 @@ RSpec.describe Types::Ci::JobType do
it
'exposes the expected fields'
do
it
'exposes the expected fields'
do
expected_fields
=
%i[
expected_fields
=
%i[
pipeline
name
name
needs
needs
detailedStatus
detailedStatus
...
...
spec/requests/api/graphql/ci/jobs_spec.rb
View file @
914bdb7b
...
@@ -34,6 +34,9 @@ RSpec.describe 'Query.project.pipeline.stages.groups.jobs' do
...
@@ -34,6 +34,9 @@ RSpec.describe 'Query.project.pipeline.stages.groups.jobs' do
jobs {
jobs {
nodes {
nodes {
name
name
pipeline {
id
}
}
}
}
}
}
}
...
@@ -53,7 +56,7 @@ RSpec.describe 'Query.project.pipeline.stages.groups.jobs' do
...
@@ -53,7 +56,7 @@ RSpec.describe 'Query.project.pipeline.stages.groups.jobs' do
end
end
context
'when fetching jobs from the pipeline'
do
context
'when fetching jobs from the pipeline'
do
it
'avoids N+1 queries'
do
it
'avoids N+1 queries'
,
:aggregate_failures
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
do
post_graphql
(
query
,
current_user:
user
)
post_graphql
(
query
,
current_user:
user
)
end
end
...
@@ -86,8 +89,27 @@ RSpec.describe 'Query.project.pipeline.stages.groups.jobs' do
...
@@ -86,8 +89,27 @@ RSpec.describe 'Query.project.pipeline.stages.groups.jobs' do
docker_jobs
=
docker_group
.
dig
(
'jobs'
,
'nodes'
)
docker_jobs
=
docker_group
.
dig
(
'jobs'
,
'nodes'
)
rspec_jobs
=
rspec_group
.
dig
(
'jobs'
,
'nodes'
)
rspec_jobs
=
rspec_group
.
dig
(
'jobs'
,
'nodes'
)
expect
(
docker_jobs
).
to
eq
([{
'name'
=>
'docker 1 2'
},
{
'name'
=>
'docker 2 2'
}])
expect
(
docker_jobs
).
to
eq
([
expect
(
rspec_jobs
).
to
eq
([{
'name'
=>
'rspec 1 2'
},
{
'name'
=>
'rspec 2 2'
}])
{
'name'
=>
'docker 1 2'
,
'pipeline'
=>
{
'id'
=>
pipeline
.
to_global_id
.
to_s
}
},
{
'name'
=>
'docker 2 2'
,
'pipeline'
=>
{
'id'
=>
pipeline
.
to_global_id
.
to_s
}
}
])
expect
(
rspec_jobs
).
to
eq
([
{
'name'
=>
'rspec 1 2'
,
'pipeline'
=>
{
'id'
=>
pipeline
.
to_global_id
.
to_s
}
},
{
'name'
=>
'rspec 2 2'
,
'pipeline'
=>
{
'id'
=>
pipeline
.
to_global_id
.
to_s
}
}
])
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment