Add latest_pipeline endpoint (#656) - #737
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 issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
The Rubocop failure here isn't from this PR — I reproduced it on
This PR only touches |
|
The Rubocop job here isn't from this PR. I ran it locally on this branch and on
None of them are in the three files this PR touches ( I've left them alone so this PR stays scoped to the endpoint. Happy to send a separate lint-only PR if that's useful -- five of the six are autocorrectable and the |
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.