From 4f438f21cd4616da82b9c40430af1e9f45482993 Mon Sep 17 00:00:00 2001 From: Akash Srivastava Date: Sun, 27 Jan 2019 21:06:11 +0530 Subject: [PATCH] Added delete_pipeline API --- lib/gitlab/client/pipelines.rb | 12 ++++++++++++ spec/gitlab/client/pipelines_spec.rb | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/gitlab/client/pipelines.rb b/lib/gitlab/client/pipelines.rb index 3222d585f..b8e71e641 100644 --- a/lib/gitlab/client/pipelines.rb +++ b/lib/gitlab/client/pipelines.rb @@ -77,5 +77,17 @@ def cancel_pipeline(project, id) def retry_pipeline(project, id) post("/projects/#{url_encode project}/pipelines/#{id}/retry") end + + # Delete a pipeline + # + # @example + # Gitlab.delete_pipeline(5, 1) + # + # @param [Integer, String] project The ID or name of a project. + # @param [Integer] id The ID of a pipeline. + # @return [void] This API call returns an empty response body. + def delete_pipeline(project, id) + delete("/projects/#{url_encode project}/pipelines/#{id}") + end end end diff --git a/spec/gitlab/client/pipelines_spec.rb b/spec/gitlab/client/pipelines_spec.rb index d483a3f99..fc4604be5 100644 --- a/spec/gitlab/client/pipelines_spec.rb +++ b/spec/gitlab/client/pipelines_spec.rb @@ -109,4 +109,15 @@ expect(@pipeline_retry.user.name).to eq('Administrator') end end + + describe '.delete_pipeline' do + before do + stub_delete('/projects/3/pipelines/46', 'empty') + Gitlab.delete_pipeline(3, 46) + end + + it 'gets the correct resource' do + expect(a_delete('/projects/3/pipelines/46')).to have_been_made + end + end end