MCPcopy Index your code
hub / github.com/buildkite/go-buildkite

github.com/buildkite/go-buildkite @v5.3.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v5.3.1 ↗ · + Follow
688 symbols 2,641 edges 145 files 280 documented · 41% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

buildkite-go Go Reference Build status

A Go library and client for the Buildkite API. This project draws a lot of its structure and testing methods from go-github.

Usage

To get the package, execute:

go get github.com/buildkite/go-buildkite/v5

Simple shortened example for listing all pipelines:

import (
    "github.com/buildkite/go-buildkite/v5"
    "github.com/alecthomas/kingpin/v2"
)

var (
    apiToken = kingpin.Flag("token", "API token").Required().String()
    org = kingpin.Flag("org", "Organization slug").Required().String()
)

client, err := buildkite.NewOpts(buildkite.WithTokenAuth(*apiToken))

if err != nil {
    log.Fatalf("client config failed: %s", err)
}

pipelines, _, err := client.Pipelines.List(*org, nil)

Migrating to v5 update payloads

Version 5 changes update request structs so PATCH requests can distinguish "leave this field unchanged" from "send this field with an empty value".

Update fields that can be cleared now use buildkite.Optional[T]. The zero value omits the field. Wrap values with buildkite.Some(...) when the field should be sent, including empty strings, empty maps, empty slices, 0, or false.

Use initialized empty slices and maps when the API expects [] or {}. Nil slices and maps wrapped with buildkite.Some(...) are encoded as null.

_, _, err := client.Pipelines.Update(ctx, org, pipelineSlug, buildkite.UpdatePipeline{
    Description:              buildkite.Some(""),
    Tags:                     buildkite.Some([]string{}),
    SkipQueuedBranchBuilds:   buildkite.Some(false),
})
_, _, err := client.PipelineSchedules.Update(ctx, org, pipelineSlug, scheduleID, buildkite.UpdatePipelineSchedule{
    Env:     buildkite.Some(map[string]string{}),
    Enabled: buildkite.Some(false),
})

Leaving an Optional[T] unset omits that field from the PATCH body:

_, _, err := client.Clusters.Update(ctx, org, clusterID, buildkite.ClusterUpdate{
    Name: buildkite.Some("macOS builders"),
    // Description is unchanged.
})

Some create/update request types were split so create calls keep plain required values while update calls use presence-aware fields:

  • ClusterTokenCreateUpdate is now ClusterTokenCreate and ClusterTokenUpdate.
  • PipelineTemplateCreateUpdate is now PipelineTemplateCreate and PipelineTemplateUpdate.
  • CreateTeam is still used for team creation; UpdateTeam is now used for team updates.
  • TestSuitesService.Update now takes TestSuiteUpdate.

See the examples directory for additional examples.

Note: not all API features are supported by go-buildkite just yet. If you need a feature, please make an issue or submit a pull request.

Releasing

  1. Generate a changelog using ghch: ghch --format=markdown --next-version=v<next-version-number>, and update it in CHANGELOG.md
  2. Commit the changelog
  3. Create a release using GitHub CLI: gh release create, ensuring you update the release notes with the new CHANGELOG.md content

License

This library is distributed under the BSD-style license found in the LICENSE file.

Extension points exported contracts — how you extend this code

ProviderSettings (Interface)
ProviderSettings represents the sum type of the settings for different source code providers. [4 implementers]
providers.go
RateLimitNotify (FuncType)
RateLimitNotify is called each time a 429 response is received, including on the final exhausted attempt where no retry
buildkite.go
ClientOpt (FuncType)
ClientOpt is a function that configures a Client.
buildkite.go

Core symbols most depended-on inside this repo

String
called by 234
timestamp.go
NewRequest
called by 151
buildkite.go
Do
called by 147
buildkite.go
Get
called by 71
meta.go
NewTimestamp
called by 69
timestamp.go
List
called by 48
teams.go
addOptions
called by 32
buildkite.go
Create
called by 32
rules.go

Shape

Function 297
Struct 207
Method 170
TypeAlias 11
FuncType 2
Interface 1

Languages

Go100%

Modules by API surface

jobs.go26 symbols
buildkite.go25 symbols
builds.go24 symbols
pipelines.go18 symbols
package_registries.go18 symbols
builds_test.go18 symbols
webhook_events.go17 symbols
clusters.go15 symbols
buildkite_test.go15 symbols
retry_test.go14 symbols
pipelines_test.go14 symbols
cluster_secrets.go14 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add go-buildkite \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page