Skip to main content
A Buildkite Secret Sync pushes secrets from Infisical into the Buildkite secrets of a cluster, where the cluster’s agents read them with buildkite-agent secret get or the secrets key of a pipeline step. Each Infisical secret becomes a Buildkite secret with the same key, unless you customize key names to add a prefix or suffix. You can also limit the synced secrets to selected pipelines in the cluster.
The Buildkite Secret Sync requires a Buildkite app connection. This guide walks you through creating a project-scoped app connection.

Prerequisites

Step 1: Create a Buildkite API access token

Infisical needs a Buildkite API access token that can read organizations, clusters, and pipelines, and read and write secrets.
1
Log in to Buildkite, open the account menu in the top right, and select Personal settings. Then select API Access Tokens.Personal Settings Menu
2
Select New API Access Token, and enter your password if Buildkite asks for it.New API Access Token
3
Fill in the form:
  • Description: A name that identifies the token, such as infisical
  • Credential Type: Token
  • Organization Access: The organizations that own the clusters you plan to sync to
  • Token Expiry: How long the token stays valid; once it expires, syncs fail until you update the connection with a new token
  • REST API Scopes: READ for Organizations, Clusters, and Pipelines, and READ and WRITE for Secrets
  • GraphQL API Access: Disabled, because Infisical uses only the REST API
Then select Create New API Access Token.Create New API Access Token
4
Copy the token and store it securely. Buildkite shows it only once.

Step 2: Set up the sync in Infisical

To create the sync using the API, use the Buildkite Create endpoint.
1
In your project, go to Integrations and open the Secret Syncs tab. Select + Add Sync.Secret Syncs TabThen, select the Buildkite sync.Select Buildkite
2
Under Source, choose which secrets to sync from Infisical:
  • Environment: The project environment to retrieve secrets from
  • Secret Path: The folder path to retrieve secrets from
  • Include secrets from all subfolders: Also syncs the secrets in every folder beneath the path
Buildkite accepts a secret only if it meets these rules:
  • The key starts with a letter, contains only letters, numbers, and underscores (_), and doesn’t start with buildkite or bk in any case
  • No other synced secret has the same key in a different case, because Buildkite treats API_KEY and api_key as the same key
  • The value is at most 32,767 bytes
If a secret breaks one of these rules, the sync fails before it writes anything, with an error that names the secret. Secrets with an empty value aren’t synced, because Buildkite doesn’t accept an empty value.
If you need to sync secrets from multiple folder locations, use secret imports.
Configure SourceThen select Continue.
3
Under Destination, create or select the Buildkite app connection the sync will use, then choose the cluster that receives the secrets.
Under Buildkite Connection, select Create Connection in the dropdown, then fill in:
  • Name: A descriptive name for the connection; it must be slug-friendly
  • Description (optional): A note for future reference
  • Method: API Token, the only method the connection supports
  • Buildkite API Access Token: The token you copied when creating a Buildkite API access token
Select Connect to Buildkite. Infisical returns you to the sync form with the new connection selected.
This creates a connection scoped to the current project. To share the connection across other projects, create it at the organization level first, then select it here.
  • Organization: The Buildkite organization that owns the cluster
  • Cluster: The Buildkite cluster to sync secrets to
  • Pipelines (optional): The pipelines in the cluster that can read the synced secrets (if you select none, the sync doesn’t set or change access policies) Configure Destination
Then select Continue.
4
Under Initial Sync Behavior, select Overwrite Buildkite, then select Continue.
Buildkite never returns the value of a secret through its API, so this sync can’t import existing Buildkite secrets into Infisical. Overwrite Buildkite is the only option.
Initial Sync Behavior
5
Under Sync Options, choose how secrets are synced:
  • Prevent secret deletion: When enabled, Infisical adds and updates secrets in Buildkite but never deletes them; enable this if you manage some of the cluster’s secrets outside of Infisical
  • Auto-sync on changes: When enabled, secrets sync to Buildkite automatically as the source changes; turn it off to sync manually only
  • Customize key names: Adds a prefix or suffix to every synced key, using {{secretKey}} for the original name and {{environment}} for the environment slug
A Buildkite cluster’s secrets are shared by every pipeline in the cluster, so a sync can change secrets that were created outside Infisical. If you don’t customize key names, the sync treats every secret in the cluster as one it manages:
  • If a Buildkite secret has the same key as an Infisical secret, the sync overwrites the Buildkite secret’s value
  • If Prevent secret deletion is off, every Buildkite secret that isn’t in Infisical is deleted
With customized key names, the sync writes only keys with your prefix or suffix, and deletes only Buildkite secrets whose keys match it.Before the first sync, customize key names or keep Prevent secret deletion on. Prevent secret deletion is on by default when you create the sync in the UI, but off unless you set disableSecretDeletion when you create it through the API.
Configure Sync OptionsThen select Continue.
6
Give the sync a Name and an optional Description. The name must be slug-friendly.Sync DetailsThen select Continue.
7
Under Set up failure alerts, choose who hears about it when the sync fails after all of its retries. The failure alert is on by default under Alert on Sync Failure, with an email to the project’s admins. Select Add channel to also notify Slack, a webhook, or PagerDuty, or turn the alert off to skip this step.Failure AlertsThen select Continue.
8
Review your Buildkite Sync configuration, then select Create Sync.Review and Create
The sync is created. If Auto-sync on changes is enabled, it begins syncing secrets to Buildkite right away.

FAQ

If you select pipelines in the Pipelines field, only builds of those pipelines can read the secrets. The sync gives each secret it writes an access policy that allows only those pipelines, and replaces any other policy the secret has.If you leave Pipelines empty, every build in the cluster can read the secrets, unless a secret has an access policy in Buildkite. The sync creates secrets without a policy and changes only the value of an existing secret, so it keeps a policy you add in Buildkite, or one it set while pipelines were selected.
Buildkite treats keys that differ only in case as the same key, so the sync deletes the old Buildkite secret and creates one with the new key. The sync fails without changing anything if the old secret can’t be replaced:
  • The sync has no pipelines selected and the old secret has an access policy, which the new secret would lose
  • The sync can’t delete the old secret, because its key doesn’t match your customized key names or Prevent secret deletion is on
To rename a secret with a policy, delete the old secret in Buildkite, let the sync create the new one, and add the policy to it.
Buildkite limits how many API requests each user can make per minute, 50 by default, and the sync makes at least one request for every secret. When the sync reaches the limit, it waits for Buildkite to reset the limit and then continues. The sync can’t tell which values changed, because Buildkite doesn’t return them, so it writes every value on every sync.To find the limits for your organization, open Settings > Quotas in Buildkite.

Next steps

Buildkite

Create an organization-level Buildkite connection to share across projects.

Secret syncs

Learn how secret syncs work and how to manage them.