From b22ed4dc8e75bf4a957373e814cc6adb9015b5df Mon Sep 17 00:00:00 2001 From: ddieulivol Date: Tue, 2 Apr 2024 14:19:46 +0200 Subject: [PATCH] Add pipeline metadata endpoint --- lib/gitlab/client/pipelines.rb | 13 +++++++++++++ spec/gitlab/client/pipelines_spec.rb | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/gitlab/client/pipelines.rb b/lib/gitlab/client/pipelines.rb index b4970544d..f0bee2850 100644 --- a/lib/gitlab/client/pipelines.rb +++ b/lib/gitlab/client/pipelines.rb @@ -101,5 +101,18 @@ def retry_pipeline(project, id) def delete_pipeline(project, id) delete("/projects/#{url_encode project}/pipelines/#{id}") end + + # Update a pipeline metadata + # + # @example + # Gitlab.update_pipeline_metadata(5, 1, name: 'new name') + # + # @param [Integer, String] project The ID or name of a project. + # @param [Integer] id The ID of a pipeline. + # @option options [String] :name The new name of the pipeline. + # @return [Gitlab::ObjectifiedHash] + def update_pipeline_metadata(project, id, options = {}) + put("/projects/#{url_encode project}/pipelines/#{id}/metadata", body: options) + end end end diff --git a/spec/gitlab/client/pipelines_spec.rb b/spec/gitlab/client/pipelines_spec.rb index b6955ffc8..65598bd0c 100644 --- a/spec/gitlab/client/pipelines_spec.rb +++ b/spec/gitlab/client/pipelines_spec.rb @@ -140,4 +140,17 @@ expect(a_delete('/projects/3/pipelines/46')).to have_been_made end end + + describe '.update_pipeline_metadata' do + before do + stub_put('/projects/3/pipelines/46/metadata', 'pipeline') + Gitlab.update_pipeline_metadata(3, 46, name: 'new pipeline name') + end + + it 'gets the correct resource' do + expect( + a_put('/projects/3/pipelines/46/metadata').with(body: { name: 'new pipeline name' }) + ).to have_been_made + end + end end