Skip to content

Commit

Permalink
Merge pull request #626 from sliaquat/run-pipeline-schedule
Browse files Browse the repository at this point in the history
Add support for running a project pipeline schedule (#625)
  • Loading branch information
NARKOZ committed Aug 31, 2021
2 parents 385df7c + c4733dc commit 06946d8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/gitlab/client/pipeline_schedules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ def pipeline_schedule_take_ownership(project, pipeline_schedule_id)
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/take_ownership")
end

# Run a scheduled pipeline immediately.
#
# @example
# Gitlab.run_pipeline_schedule(5, 1)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] trigger_id The pipeline schedule ID.
# @return [Gitlab::ObjectifiedHash] Pipeline created message.
def run_pipeline_schedule(project, pipeline_schedule_id)
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/play")
end

# Delete a pipeline schedule.
#
# @example
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/pipeline_schedule_run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"message": "201 Created"}
15 changes: 15 additions & 0 deletions spec/gitlab/client/pipeline_schedules_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@
end
end

describe '.run_pipeline_schedule' do
before do
stub_post('/projects/3/pipeline_schedules/13/play', 'pipeline_schedule_run')
@pipeline_schedule_run = Gitlab.run_pipeline_schedule(3, 13)
end

it 'gets the correct resource' do
expect(a_post('/projects/3/pipeline_schedules/13/play')).to have_been_made
end

it 'returns created message' do
expect(@pipeline_schedule_run).to be_a Gitlab::ObjectifiedHash
end
end

describe '.delete_pipeline_schedule' do
before do
stub_delete('/projects/3/pipeline_schedules/13', 'pipeline_schedule')
Expand Down

0 comments on commit 06946d8

Please sign in to comment.