Skip to content

Commit

Permalink
Add pipeline bridges API
Browse files Browse the repository at this point in the history
  • Loading branch information
caalberts committed Nov 18, 2020
1 parent 34f4a91 commit 06977b8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/gitlab/client/jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ def pipeline_jobs(project_id, pipeline_id, options = {})
get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/jobs", query: options)
end

# Gets a list of Bridge Jobs from a pipeline
#
# @example
# Gitlab.pipeline_bridges(1, 2)
# Gitlab.pipeline_bridges("project", 2)
#
# @param [Integer, String] The ID or name of a project.
# @param [Integer] the id of the pipeline
# @param [Hash] options A customizable set of options.
# @option options [Array] :scope The scope of bridge jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all bridge jobs if none provided.
# @return [Array<Gitlab::ObjectifiedHash>]
def pipeline_bridges(project_id, pipeline_id, options = {})
get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/bridges", query: options)
end

# Gets a single job
#
# @example
Expand Down
22 changes: 22 additions & 0 deletions spec/gitlab/client/jobs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@
end
end

describe '.pipeline_bridges' do
before do
stub_get('/projects/1/pipelines/1/bridges', 'pipeline_bridges')
@jobs = Gitlab.pipeline_bridges(1, 1)
end

it 'gets the correct resource' do
expect(a_get('/projects/1/pipelines/1/bridges')).to have_been_made
end
end

describe '.pipeline_bridges - with scope' do
before do
stub_get('/projects/1/pipelines/1/bridges?scope[]=running&scope[]=created', 'pipeline_bridges')
@jobs = Gitlab.pipeline_bridges(1, 1, scope: %w[running created])
end

it 'gets the correct resource' do
expect(a_get('/projects/1/pipelines/1/bridges?scope[]=running&scope[]=created')).to have_been_made
end
end

describe '.job' do
before do
stub_get('/projects/1/jobs/1', 'job')
Expand Down

0 comments on commit 06977b8

Please sign in to comment.