Buildkite Bazel Pipeline Example

This repository is an example Buildkite pipeline that uses Bazel to build a C++ project.

See the full Getting Started Guide for step-by-step instructions on how to get this running.

Screenshot of Buildkite Bazel example pipeline

How it works

The empty WORKSPACE file marks the directory as a Bazel workspace, and main/BUILD defines the build targets.

The pipeline.yml tells Bazel to build the hello-world target in main/BUILD:

steps:
  - label: ":bazel: Build"
    commands:
      - bazel build //main:hello-world

The hello-world target uses the Bazelcc_binary rule to build a hello-world executable from the source file hello-world.cc.

If you want to test the result by running the resulting binary, add the following line to your copy of the Pipeline:

        - bazel-bin/main/hello-world

Setup

You’ll need some dependencies installed alongside your Buildkite Agent:

An example Dockerfile for an image with the agent and these dependencies:

FROM buildkite/agent:3

# Install gcc etc
RUN apt-get update && apt-get install -y build-essential

ARG TARGETOS
ARG TARGETARCH

# Install bazelisk
ADD --chmod=0755 https://github.com/bazelbuild/bazelisk/releases/download/v1.26.0/bazelisk-${TARGETOS}-${TARGETARCH} /usr/local/bin/bazel

# or a specific version of Bazel, if you want to lock it down
#ADD --chmod=0755 https://releases.bazel.build/8.2.1/release/bazel-8.2.1-${TARGETOS}-${TARGETARCH} /usr/local/bin/bazel

On macOS, you can use Homebrew to install the Buildkite Agent and Bazelisk:

brew install bazelisk

Homebrew should prompt you to install Xcode Command Line Tools which includes a C++ compiler. If not:

xcode-select --install

License

See LICENSE (MIT)

More examples

Start turning complexity into an advantage

Create an account to get started with a 30-day free trial. No credit card required.

Buildkite Pipelines

Platform

  1. Pipelines
  2. Public pipelines
  3. Test Engine
  4. Package Registries
  5. Mobile Delivery Cloud
  6. Pricing

Hosting options

  1. Self-hosted agents
  2. Mac hosted agents
  3. Linux hosted agents

Resources

  1. Docs
  2. Blog
  3. Changelog
  4. Example pipelines
  5. Plugins
  6. Webinars
  7. Case studies
  8. Events
  9. Migration Services
  10. Comparisons

Company

  1. About
  2. Careers
  3. Press
  4. Security
  5. Brand assets
  6. Contact

Solutions

  1. Replace Jenkins
  2. Workflows for AI/ML
  3. Testing at scale
  4. Monorepo mojo
  5. Bazel orchestration

Legal

  1. Terms of Service
  2. Acceptable Use Policy
  3. Privacy Policy
  4. Subprocessors
  5. Service Level Agreement

Support

  1. System status
  2. Forum
© Buildkite Pty Ltd 2025