diff options
Diffstat (limited to 'app/graphql/mutations/ci/pipeline_cancel.rb')
-rw-r--r-- | app/graphql/mutations/ci/pipeline_cancel.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/graphql/mutations/ci/pipeline_cancel.rb b/app/graphql/mutations/ci/pipeline_cancel.rb new file mode 100644 index 00000000000..bc881e2ac02 --- /dev/null +++ b/app/graphql/mutations/ci/pipeline_cancel.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Mutations + module Ci + class PipelineCancel < Base + graphql_name 'PipelineCancel' + + authorize :update_pipeline + + def resolve(id:) + pipeline = authorized_find!(id: id) + + if pipeline.cancelable? + pipeline.cancel_running + { success: true, errors: [] } + else + { success: false, errors: ['Pipeline is not cancelable'] } + end + end + end + end +end |