Skip to content

Commit

Permalink
Add pipeline bridges API (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
caalberts authored Nov 28, 2020
1 parent 50c5625 commit 8b8a34d
Show file tree
Hide file tree
Showing 3 changed files with 38 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
1 change: 1 addition & 0 deletions spec/fixtures/pipeline_bridges.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"commit":{"author_email":"admin@example.com","author_name":"Administrator","created_at":"2015-12-24T16:51:14.000+01:00","id":"0ff3ae198f8601a285adcf5c0fff204ee6fba5fd","message":"Test the CI integration.","short_id":"0ff3ae19","title":"Test the CI integration."},"coverage":null,"allow_failure":false,"created_at":"2015-12-24T15:51:21.802Z","started_at":"2015-12-24T17:54:27.722Z","finished_at":"2015-12-24T17:58:27.895Z","duration":240,"id":7,"name":"teaspoon","pipeline":{"id":6,"ref":"master","sha":"0ff3ae198f8601a285adcf5c0fff204ee6fba5fd","status":"pending","created_at":"2015-12-24T15:50:16.123Z","updated_at":"2015-12-24T18:00:44.432Z","web_url":"https://example.com/foo/bar/pipelines/6"},"ref":"master","stage":"test","status":"pending","tag":false,"web_url":"https://example.com/foo/bar/-/jobs/7","user":{"id":1,"name":"Administrator","username":"root","state":"active","avatar_url":"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon","web_url":"http://gitlab.dev/root","created_at":"2015-12-21T13:14:24.077Z","bio":null,"location":null,"public_email":"","skype":"","linkedin":"","twitter":"","website_url":"","organization":""},"downstream_pipeline":{"id":5,"sha":"f62a4b2fb89754372a346f24659212eb8da13601","ref":"master","status":"pending","created_at":"2015-12-24T17:54:27.722Z","updated_at":"2015-12-24T17:58:27.896Z","web_url":"https://example.com/diaspora/diaspora-client/pipelines/5"}}]
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 8b8a34d

Please sign in to comment.