Skip to content

Buildkite

Trigger Smoketest deployment webhooks from Buildkite after a deployment step.

View as Markdown

Use Buildkite when deployment is represented as a command step. Add a command step after deploy and pass Buildkite's commit, branch, and build metadata to Smoketest.

Before you start

  1. Create a deployment webhook in Smoketest.
  2. Store SMOKETEST_DEPLOYMENT_WEBHOOK_URL as a pipeline secret or agent-provided environment variable.
  3. Set DEPLOYMENT_URL in the pipeline, a hook, or the deploy command.

Pipeline example

.buildkite/pipeline.yml
steps:
  - label: ":rocket: Deploy"
    command: "./scripts/deploy.sh"

  - wait

  - label: ":white_check_mark: Smoketest"
    command: |
      curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
        -H "Idempotency-Key: $BUILDKITE_BUILD_ID" \
        --data-urlencode "targetUrl=$DEPLOYMENT_URL" \
        --data-urlencode "commitSha=$BUILDKITE_COMMIT" \
        --data-urlencode "branch=$BUILDKITE_BRANCH" \
        --data-urlencode "externalId=$BUILDKITE_BUILD_ID"
    env:
      DEPLOYMENT_URL: "https://staging.example.com"

Preview deployments

If your deploy step returns the preview URL, run Smoketest in the same command step or store the URL in Buildkite metadata.

.buildkite/pipeline.yml
steps:
  - label: ":rocket: Deploy preview"
    command: |
      DEPLOYMENT_URL="$(./scripts/deploy-preview.sh)"
      buildkite-agent meta-data set deployment-url "$DEPLOYMENT_URL"

  - wait

  - label: ":white_check_mark: Smoketest preview"
    command: |
      DEPLOYMENT_URL="$(buildkite-agent meta-data get deployment-url)"
      curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
        -H "Idempotency-Key: $BUILDKITE_BUILD_ID" \
        --data-urlencode "targetUrl=$DEPLOYMENT_URL" \
        --data-urlencode "commitSha=$BUILDKITE_COMMIT" \
        --data-urlencode "branch=$BUILDKITE_BRANCH" \
        --data-urlencode "externalId=$BUILDKITE_BUILD_ID"

On this page