Buildkite
Learn how to use Buildkite with Turborepo.
The following example shows how to use Turborepo with Buildkite.
For a given root package.json:
{
"name": "my-turborepo",
"scripts": {
"build": "turbo run build",
"test": "turbo run test"
},
"devDependencies": {
"turbo": "latest"
}
}And a turbo.json:
{
"$schema": "https://turborepo.dev/schema.json",
"tasks": {
"build": {
"outputs": [".next/**", "!.next/cache/**"],
"dependsOn": ["^build"]
},
"test": {
"dependsOn": ["^build"]
}
}
}Create a file called .buildkite/pipeline.yml in your repository with the following contents:
steps:
- label: ":test_tube: Test"
command: |
pnpm install
pnpm test
- label: ":hammer: Build"
command: |
pnpm install
pnpm buildsteps:
- label: ":test_tube: Test"
command: |
yarn
yarn test
- label: ":hammer: Build"
command: |
yarn
yarn buildsteps:
- label: ":test_tube: Test"
command: |
npm install
npm test
- label: ":hammer: Build"
command: |
npm install
npm run buildsteps:
- label: ":test_tube: Test"
command: |
bun install
bun run test
- label: ":hammer: Build"
command: |
bun install
bun run buildCreate a Pipeline
To create your pipeline in the Buildkite dashboard, you'll need to first upload the pipeline definition from your repository.
-
Select Pipelines to navigate to the Buildkite dashboard.
-
Select New pipeline.
-
Enter your pipeline's details in the respective Name and Description fields.
-
In the Steps editor, ensure there's a step to upload the definition from your repository:
steps:
- label: ":pipeline:"
command: buildkite-agent pipeline upload- Select Create Pipeline, then click New Build, then select Create Build.
Run the pipeline whenever you make changes you want to verify.
Remote Caching
To use Remote Caching, retrieve the team and token for the Remote Cache for your provider. In this example, we'll use Vercel Remote Cache:
TURBO_TOKEN- The Bearer token to access the Remote CacheTURBO_TEAM- The account to which the monorepo belongs
To use Vercel Remote Caching, you can get the value of these variables in a few steps:
-
Create a Scoped Access Token to your account in the Vercel Dashboard. Copy the value to a safe place. You'll need it in a moment.

-
Obtain your Team URL and copy its value as well. Both values will be used in the next step.
-
In the Buildkite dashboard, create two new Buildkite secrets, one for each value. Name them
TURBO_TOKENandTURBO_TEAM. -
Update
pipeline.ymlto fetch and applyTURBO_TOKENandTURBO_TEAMas environment variables with the Buildkite Secrets plugin as shown. (For additional secret-management options, read Managing pipeline secrets in the Buildkite documentation.)steps: - label: ":test_tube: Test" command: | npm install npm test plugins: - secrets: variables: TURBO_TOKEN: TURBO_TOKEN TURBO_TEAM: TURBO_TEAM - label: ":hammer: Build" command: | npm install npm run build plugins: - secrets: variables: TURBO_TOKEN: TURBO_TOKEN TURBO_TEAM: TURBO_TEAMCommit and push these changes to your repository, and on the next pipeline run, the secrets will be applied and Vercel Remote Caching will be active.