Skip to main content

Buildkite

CatalogScorecards

Buildkite is a continuous integration and delivery platform that enablers users to run fast, secure, and scalabe pipelines on their own infrastructure.

By integrating Buildkite with Cortex, you can drive insights into your CI/CD pipelines and pull in metrics about your builds and pipelines.

Setup and configuration

Getting started

In order to connect Cortex to your Buildkite account, you’ll need to create an API access token. You need to be a member of a Buildkite organization to generate and use an access token for it.

You can generate an access token from Buildkite personal setings. While Buildkite offers very granular options for configuring the token's scope, Cortex just needs read-only permissions for pipelines and builds.

caution

In order to create and use a Buildkite access token, you need to be a member of the given organization.

Configuration

Once you've created a Buildkite access token, you can configure the integration in Cortex from Buildkite page in settings.

caution

If you do not see the settings page you're looking for, you likely don't have the proper permissions and need to contact your admin.

To configure the integration, provide the following information:

  • API token: Buildkite access token generated earlier.
  • Organization slug: Slug for your Buildkite organization (e.g. cortex-apps).
    • This can be found in your organization's settings or at the end of your Buildkite URL by selecting Pipelines in the global navigation of your organization.

Registration

Discovery

By default, Cortex will use the entity tag (e.g. my-entity) for your Buildkite pipeline. For example, if your entity tag is my-pipeline, then the corresponding pipeline tag in Buildkite should also be my-pipeline.

Cortex will also use the the GitHub, GitLab, Bitbucket, or Azure DevOps repository to connect entities to Buildkite pipelines. For example, if the GitHub repo associated with your Buildkite pipeline is my-org/repo, then entities in Cortex that also live in my-org/repo will populate with details from that pipeline.

Entity descriptor

You can add Buildkite pipelines to an entity by defining the pipeline slug or tags with one of the following blocks in the entity descriptor.

x-cortex-ci-cd:
buildkite:
pipelines:
- slug: my-buildkite-pipeline-slug-1
- slug: my-buildkite-pipeline-slug-2
x-cortex-ci-cd:
buildkite:
tags:
- tag: my-buildkite-tag-1
- tag: my-buildkite-tag-2
tip

The slug for your pipeline can be found in the Buildkite URL for a given pipeline (e.g. https://buildkite.com/{ORG_NAME}/{PIPELINE_SLUG})

Expected results

Entity pages

Once the Buildkite integration is established, Cortex will automatically pull in pipeline data to an entity's page. You can access this data from the Buildkite page under Integrations in the side panel.

You can find a list of pipeline runs for each pipeline linked to a given entity on this page:

  • Pipeline slug/tag
  • Action (e.g. "scheduled build")
  • Timestamp
  • Branch
  • State

The state for a build will appear as a tag next to the pipeline slug/tag (e.g. canceled, passed, or failed).

Scorecards and CQL

With the Buildkite integration, you can create Scorecard rules and write CQL queries based on Buildkite pipelines.

  • Check if Buildkite pipelines are set: Checks if an entity has registered pipelines in its descriptor.
  • Get Buildkite builds: Gets pipelines and builds that meet given criteria.
    • Build criteria:
      • Branch
      • Commit
      • Created at
      • ID
      • Message
      • Number
      • Pipeline
      • State
    • Pipeline criteria:
      • Description
      • Git repository
      • ID
      • Name
      • Slug
      • Tags
  • Get Buildkite pipelines: Gets all pipelines associated with an entity or all pipelines associated with an entity that meet given criteria.
    • Description
    • Git repository
    • ID
    • Name
    • Slug
    • Tags

Real-world examples

For a Scorecard focused on production readiness, you can pull in data from Buildkite to make sure that entities belong to a CI/CD pipeline.

buildkite != null

Or you can confirm that there are pipelines linked to a specific repository.

buildkite.pipelines().any((pipeline) => pipeline.git_repository = {"org/repo-name"})

If you're building a Scorecard with an emphasis on operational maturity, you could set a rule to make sure not only that entities belong to a pipeline, but that the pipeline is functioning as expected.

buildkite.builds(states["passed"]).length >=1

Still need help?

The following are all the ways to get assistance from our customer engineering team. Please use the option that is best for your users:

  • Email: help@cortex.io, or open a support ticket in the in app Resource Center
  • Chat: Available in the Resource Center
  • Slack: Users with a connected Slack channel will have a workflow added to their account. From here, you can either @CortexTechnicalSupport or add a :ticket: reaction to a question in Slack, and the team will respond directly.

Don’t have a Slack channel? Talk with your customer success manager.