Pulumi Any Terraform

Buildkite Provider

Manage Buildkite CI/CD pipelines, agents, clusters, and teams with Pulumi

The Buildkite provider enables you to manage CI/CD pipelines, agent clusters, teams, and organization resources in Buildkite using Pulumi. This provider is dynamically bridged from the Terraform Buildkite Provider.

Installation

Install the Buildkite provider package using your preferred package manager:

bun add pulumi-buildkite
pnpm add pulumi-buildkite
yarn add pulumi-buildkite
npm install pulumi-buildkite

Configuration

Set up your Buildkite API credentials:

pulumi config set buildkite:apiToken "your-api-token" --secret
pulumi config set buildkite:organization "your-org-slug"

Or use environment variables:

export BUILDKITE_API_TOKEN="your-api-token"
export BUILDKITE_ORGANIZATION_SLUG="your-org-slug"

Quick Start

import * as pulumi from "@pulumi/pulumi";
import * as buildkite from "pulumi-buildkite";

// Create a pipeline
const pipeline = new buildkite.Pipeline("my-app", {
    name: "My Application",
    repository: "https://github.com/myorg/myapp.git",
    defaultBranch: "main",
    steps: `
steps:
  - label: ":hammer: Build"
    command: "npm run build"
  - label: ":test_tube: Test"
    command: "npm test"
`,
});

export const pipelineSlug = pipeline.slug;

Key Features

Pipelines

Create and manage CI/CD pipelines with build steps, schedules, and webhooks:

const pipeline = new buildkite.Pipeline("deploy", {
    name: "Deploy Pipeline",
    repository: "https://github.com/myorg/myapp.git",
    defaultBranch: "main",
    steps: `
steps:
  - label: ":rocket: Deploy"
    command: "./deploy.sh"
    branches: "main"
`,
});

// Add a nightly build schedule
const schedule = new buildkite.PipelineSchedule("nightly", {
    pipelineId: pipeline.id,
    label: "Nightly Build",
    cronline: "0 0 * * *",
    branch: "main",
    enabled: true,
});

Clusters

Organize build agents into clusters with queues and secrets:

const cluster = new buildkite.Cluster("production", {
    name: "Production",
    description: "Production build agents",
});

const queue = new buildkite.ClusterQueue("default", {
    clusterId: cluster.id,
    key: "default",
    description: "Default build queue",
});

const secret = new buildkite.ClusterSecret("npm-token", {
    clusterId: cluster.id,
    key: "NPM_TOKEN",
    value: "your-npm-token",
});

Teams

Configure teams and manage access to pipelines:

const team = new buildkite.Team("developers", {
    name: "Developers",
    privacy: "VISIBLE",
    defaultMemberRole: "MEMBER",
    isDefaultTeam: false,
});

const access = new buildkite.PipelineTeam("dev-access", {
    pipelineId: pipeline.id,
    teamId: team.id,
    accessLevel: "BUILD_AND_READ",
});

Agent Tokens

Manage agent registration tokens:

const agentToken = new buildkite.AgentToken("ci-agents", {
    description: "Token for CI build agents",
});

export const token = agentToken.token;

Common Use Cases

CI/CD Pipeline with Testing

import * as pulumi from "@pulumi/pulumi";
import * as buildkite from "pulumi-buildkite";

const testPipeline = new buildkite.Pipeline("test-pipeline", {
    name: "Test & Deploy",
    repository: "https://github.com/myorg/myapp.git",
    defaultBranch: "main",
    steps: `
steps:
  - group: ":test_tube: Tests"
    steps:
      - label: ":npm: Unit Tests"
        command: "npm test"
      - label: ":cypress: E2E Tests"
        command: "npm run test:e2e"
  - wait
  - label: ":rocket: Deploy"
    command: "./deploy.sh"
    branches: "main"
`,
});

Multi-Cluster Setup

const stagingCluster = new buildkite.Cluster("staging", {
    name: "Staging",
    description: "Staging environment agents",
});

const prodCluster = new buildkite.Cluster("production", {
    name: "Production",
    description: "Production environment agents",
});

// Create agent tokens for each cluster
const stagingToken = new buildkite.ClusterAgentToken("staging-token", {
    clusterId: stagingCluster.id,
    description: "Staging agent token",
});

const prodToken = new buildkite.ClusterAgentToken("prod-token", {
    clusterId: prodCluster.id,
    description: "Production agent token",
});

Resource Types

ResourceDescription
PipelineCI/CD pipeline management
PipelineScheduleScheduled builds for pipelines
PipelineTeamTeam access to pipelines
PipelineTemplateReusable pipeline templates
PipelineWebhookWebhook integrations
ClusterAgent cluster management
ClusterQueueQueues within clusters
ClusterSecretSecrets stored in clusters
ClusterAgentTokenAgent tokens for clusters
TeamTeam management
TeamMemberTeam membership
AgentTokenAgent registration tokens
OrganizationOrganization settings
OrganizationRuleOrganization rules
TestSuiteTest analytics suites
RegistryPackage registries

Getting Help

On this page