class WarpEngine::CI::Woodpecker::Client
A minimal JSON client of the Woodpecker REST API, authenticated with a bearer token. Every call returns the parsed JSON (nil for an empty body), raises CI::ConnectionError when the server cannot be reached and CI::ApiError for an error status or a non-JSON body.
Public Class Methods
Source
# File lib/warp_engine/ci/woodpecker/client.rb, line 15 def initialize(url:, token:) @base_url = url.to_s.chomp("/") @token = token end
- url
-
the
Woodpeckerserver URL (a trailing slash is dropped) - token
-
the API token sent as
Authorization: Bearer
Public Instance Methods
Source
# File lib/warp_engine/ci/woodpecker/client.rb, line 31 def activate_repo(repo_id) post("/api/repos", body: { id: repo_id }) end
POST /api/repos: enables CI for the forge repository repo_id.
# File lib/warp_engine/ci/woodpecker/client.rb, line 46 def create_secret(repo_id, name:, value:, events: %w[push tag deployment]) post("/api/repos/#{repo_id}/secrets", body: { name: name, value: value, events: events }) end
POST /api/repos/:repo_id/secrets: creates the secret name with value, available to the events.
Source
# File lib/warp_engine/ci/woodpecker/client.rb, line 36 def deactivate_repo(repo_id) delete("/api/repos/#{repo_id}") end
DELETE /api/repos/:repo_id: disables CI for the repository.
# File lib/warp_engine/ci/woodpecker/client.rb, line 58 def delete_secret(repo_id, secret_name) delete("/api/repos/#{repo_id}/secrets/#{secret_name}") end
DELETE /api/repos/:repo_id/secrets/:secret_name: deletes the secret.
# File lib/warp_engine/ci/woodpecker/client.rb, line 74 def get_pipeline(repo_id, number) get("/api/repos/#{repo_id}/pipelines/#{number}") end
GET /api/repos/:repo_id/pipelines/:number: returns the pipeline Hash.
Source
# File lib/warp_engine/ci/woodpecker/client.rb, line 26 def get_repo(repo_id) get("/api/repos/#{repo_id}") end
GET /api/repos/:repo_id: returns the repository Hash.
Source
# File lib/warp_engine/ci/woodpecker/client.rb, line 69 def latest_pipeline(repo_id) get("/api/repos/#{repo_id}/pipelines/latest") end
GET /api/repos/:repo_id/pipelines/latest: returns the latest pipeline Hash.
# File lib/warp_engine/ci/woodpecker/client.rb, line 63 def list_pipelines(repo_id, page: 1, per_page: 25) get("/api/repos/#{repo_id}/pipelines", params: { page: page, perPage: per_page }) end
GET /api/repos/:repo_id/pipelines: returns one page of pipeline Hashes.
Source
# File lib/warp_engine/ci/woodpecker/client.rb, line 21 def list_repos get("/api/repos") end
GET /api/repos: returns the Array of repository Hashes the token can see.
Source
# File lib/warp_engine/ci/woodpecker/client.rb, line 41 def list_secrets(repo_id) get("/api/repos/#{repo_id}/secrets") end
GET /api/repos/:repo_id/secrets: returns the Array of secret Hashes (without values).
# File lib/warp_engine/ci/woodpecker/client.rb, line 79 def trigger_pipeline(repo_id, branch: "main") post("/api/repos/#{repo_id}/pipelines", body: { branch: branch }) end
POST /api/repos/:repo_id/pipelines: starts a pipeline on branch and returns its Hash.
# File lib/warp_engine/ci/woodpecker/client.rb, line 52 def update_secret(repo_id, secret_name, value:) patch("/api/repos/#{repo_id}/secrets/#{secret_name}", body: { value: value }) end
PATCH /api/repos/:repo_id/secrets/:secret_name: sets a new value.