Open
Conversation
Wraps GET /projects/:id/pipelines/latest from the GitLab Pipelines API. The new method takes an optional :ref to fetch the latest pipeline for a specific branch or tag (defaults to the project's default branch when omitted). Adds an rspec spec covering both the no-ref and explicit-ref paths and a latest_pipeline.json fixture that mirrors the existing pipeline.json shape.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #656.
Wraps the GitLab REST endpoint `GET /projects/:id/pipelines/latest` (docs).
Usage
```ruby
Gitlab.latest_pipeline(5) # latest pipeline on the project's default branch
Gitlab.latest_pipeline(5, ref: 'develop') # latest pipeline on a specific ref
```
The method follows the same shape as the existing `pipeline` / `pipelines` methods in `lib/gitlab/client/pipelines.rb` and forwards `:ref` (and any other future query params) through `get`'s `query:` argument so callers don't have to remember which params the endpoint supports today.
Tests
`spec/gitlab/client/pipelines_spec.rb` adds two contexts:
Backed by a new `spec/fixtures/latest_pipeline.json` fixture mirroring the existing `pipeline.json` shape.
I could not run `bundle exec rspec` locally — system Ruby is 2.6 and the gemspec requires Ruby 3.2. `ruby -c` confirms the source and spec parse cleanly. Happy to fix anything CI flags.