Buildkite Monorepo Example

This repository demonstrates a Buildkite setup for managing multiple pipelines within a single monorepo using the monorepo-diff plugin.

👉 See these examples in action:

See the full Getting Started Guide and How to set up Continuous Integration for a monorepo using Buildkite for step-by-step instructions on how to get this running.

Screenshot of the root monorepo pipeline

Root pipeline: detects changed folders and triggers service/test pipelines

Screenshot of service-app pipeline

Service App pipeline: triggered by changes to service-app/

Screenshot of test pipeline

Test pipeline: triggered by changes to test/

How it works

This repository contains:

  • A root pipeline (.buildkite/pipeline.yml) that uses the monorepo-diff plugin to detect changes and trigger sub-pipelines.
  • A service-app folder with its own .buildkite/pipeline.yml
  • A test folder with its own .buildkite/pipeline.yml

Each sub-pipeline is triggered when files within its folder change.

First time running this?

If you trigger a build without making changes to service-app/ or test/, you’ll see:

  • A ✅ green build
  • A message at the top of the build (in the Annotations tab) saying: “No changes detected - no pipelines triggered.”

This is expected! The root pipeline uses the monorepo-diff plugin to only trigger pipelines when changes are detected in watched folders.

💡 Tip: To test it out, try committing a small change inside service-app/ or test/.

Setup

To get started, fork this repository and create the pipelines using the buttons below.

You can watch any directory in your monorepo by specifying the watch attribute and its path in the root pipeline.

For a step-by-step walkthrough, see: How to set up Continuous Integration for a monorepo using Buildkite

Project Directories Structure (simplified)

.
├── .buildkite
│   ├── pipeline.yml            # Root pipeline: uses monorepo-diff
│   ├── scripts
│   │   └── git-diff-files.sh   # Diff script for detecting changes
├── service-app
│   ├── .buildkite
│   │   └── pipeline.yml        # service-app pipeline definition
└── test
    ├── .buildkite
    │   └── pipeline.yml        # test pipeline definition
├── README.md

Root Pipeline Example

The root pipeline uses the monorepo-diff plugin:

steps:
  - label: "Detect changed projects"
    plugins:
      - monorepo-diff#v1.3.0:
          diff: .buildkite/scripts/git-diff-files.sh
          watch:
            - path: "service-app"
              config:
                trigger: "monorepo-service-app-example"
            - path: "test"
              config:
                trigger: "monorepo-test-example"

Sub-Pipeline Setup

Each triggered pipeline (e.g. monorepo-service-app-example) should have a step like the following in its pipeline settings, so it knows which config file to load:

For the monorepo-service-app-example pipeline:

steps:
  - label: ":pipeline:"
    command: "buildkite-agent pipeline upload service-app/.buildkite/pipeline.yml"

For the monorepo-test-example pipeline:

steps:
  - label: ":pipeline:"
    command: "buildkite-agent pipeline upload test/.buildkite/pipeline.yml"

💡 You can configure this in the Buildkite UI under Pipeline Settings → Steps, or commit a .buildkite/pipeline.yml file directly in the appropriate folder and use it as the pipeline source.

⚠️ Avoid recursion!

Each pipeline points to the same repository. To avoid recursively loading the root pipeline again (which could cause infinite loops), each sub-pipeline should explicitly upload its own .buildkite/pipeline.yml using:

command: "buildkite-agent pipeline upload path/to/.buildkite/pipeline.yml"

GitHub Webhook Setup

Ensure GitHub webhooks or GitHub App integration is enabled for the repository:

  • Go to Pipeline Settings → GitHub and follow the instructions.
  • Enable Push and Pull Request events.

Create the Pipelines

1. Create the Root Pipeline

This pipeline uses the monorepo-diff plugin to detect changes and trigger the sub-pipelines.

📄 View the full root pipeline template.


2. Create the Service App Pipeline

This pipeline will run whenever changes are detected in the service-app/ folder.

📄 View the full service-app pipeline template.


3. Create the Test Pipeline

This pipeline will run whenever changes are detected in the test/ folder.

📄 View the full test pipeline template.


License

See LICENSE.md (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