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
50e1a148
Commit
50e1a148
authored
Aug 28, 2020
by
lauraMon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates cancel pipeline mutation
* Moves pipeline field to base mutation * Updates specs * Adds a changelog
parent
17162a49
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
17 deletions
+49
-17
app/graphql/mutations/ci/pipeline_cancel.rb
app/graphql/mutations/ci/pipeline_cancel.rb
+9
-7
changelogs/unreleased/lm-update-pipeline-mutation.yml
changelogs/unreleased/lm-update-pipeline-mutation.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
+14
-0
spec/requests/api/graphql/mutations/ci/pipeline_cancel_spec.rb
...requests/api/graphql/mutations/ci/pipeline_cancel_spec.rb
+16
-10
No files found.
app/graphql/mutations/ci/pipeline_cancel.rb
View file @
50e1a148
...
...
@@ -2,18 +2,20 @@
module
Mutations
module
Ci
class
PipelineCancel
<
Base
Mutation
class
PipelineCancel
<
Base
graphql_name
'PipelineCancel'
authorize
:update_pipeline
def
resolve
result
=
::
Ci
::
CancelUserPipelinesService
.
new
.
execute
(
current_user
)
def
resolve
(
id
:)
pipeline
=
authorized_find!
(
id:
id
)
{
success:
result
.
success?
,
errors:
[
result
&
.
message
]
}
if
pipeline
.
cancelable?
pipeline
.
cancel_running
{
success:
true
,
errors:
[]
}
else
{
success:
false
,
errors:
[
'Pipeline is not cancelable'
]
}
end
end
end
end
...
...
changelogs/unreleased/lm-update-pipeline-mutation.yml
0 → 100644
View file @
50e1a148
---
title
:
'
GraphQL:
Updates
PipelineCancel
mutation'
merge_request
:
40764
author
:
type
:
changed
doc/api/graphql/reference/gitlab_schema.graphql
View file @
50e1a148
...
...
@@ -10656,6 +10656,11 @@ input PipelineCancelInput {
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
"""
The
id
of
the
pipeline
to
mutate
"""
id
:
CiPipelineID
!
}
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
50e1a148
...
...
@@ -31967,6 +31967,20 @@
"description": "Autogenerated input type of PipelineCancel",
"fields": null,
"inputFields": [
{
"name": "id",
"description": "The id of the pipeline to mutate",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "CiPipelineID",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
spec/requests/api/graphql/mutations/ci/pipeline_cancel_spec.rb
View file @
50e1a148
...
...
@@ -7,9 +7,14 @@ RSpec.describe 'PipelineCancel' do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
:running
,
project:
project
,
user:
user
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
user:
user
)
}
let
(
:mutation
)
{
graphql_mutation
(
:pipeline_cancel
,
{},
'errors'
)
}
let
(
:mutation
)
do
variables
=
{
id:
pipeline
.
to_global_id
.
to_s
}
graphql_mutation
(
:pipeline_cancel
,
variables
,
'errors'
)
end
let
(
:mutation_response
)
{
graphql_mutation_response
(
:pipeline_cancel
)
}
...
...
@@ -17,24 +22,25 @@ RSpec.describe 'PipelineCancel' do
project
.
add_maintainer
(
user
)
end
it
'reports the service-level error'
do
service
=
double
(
execute:
ServiceResponse
.
error
(
message:
'Error canceling pipeline'
))
allow
(
::
Ci
::
CancelUserPipelinesService
).
to
receive
(
:new
).
and_return
(
service
)
it
'does not cancel any pipelines not owned by the current user'
do
build
=
create
(
:ci_build
,
:running
,
pipeline:
pipeline
)
post_graphql_mutation
(
mutation
,
current_user:
create
(
:user
))
expect
(
mutation_response
).
to
include
(
'errors'
=>
[
'Error canceling pipeline'
])
expect
(
graphql_errors
).
not_to
be_empty
expect
(
build
).
not_to
be_canceled
end
it
'
does not change any pipelines not owned by the current user
'
do
build
=
create
(
:ci_build
,
:
running
,
pipeline:
pipeline
)
it
'
returns a error if the pipline cannot be be canceled
'
do
build
=
create
(
:ci_build
,
:
success
,
pipeline:
pipeline
)
post_graphql_mutation
(
mutation
,
current_user:
create
(
:user
)
)
post_graphql_mutation
(
mutation
,
current_user:
user
)
expect
(
mutation_response
).
to
include
(
'errors'
=>
include
(
eq
'Pipeline is not cancelable'
))
expect
(
build
).
not_to
be_canceled
end
it
"cancels all
of the current user's cancelable pipelines
"
do
it
"cancels all
cancelable builds from a pipeline
"
do
build
=
create
(
:ci_build
,
:running
,
pipeline:
pipeline
)
post_graphql_mutation
(
mutation
,
current_user:
user
)
...
...
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