Skip to content

Bitbucket Pipelines

Trigger Smoketest deployment webhooks from Bitbucket Pipelines after a deploy step.

View as Markdown

Use Bitbucket Pipelines when deployment is part of your bitbucket-pipelines.yml. The post-deploy step can pass Smoketest the deployed URL, commit SHA, branch, and build number.

Before you start

  1. Create a deployment webhook in Smoketest.
  2. Add SMOKETEST_DEPLOYMENT_WEBHOOK_URL as a secured repository or deployment variable.
  3. Add DEPLOYMENT_URL as a deployment variable for each Bitbucket deployment environment.

Pipeline example

bitbucket-pipelines.yml
pipelines:
  branches:
    main:
      - step:
          name: Deploy
          deployment: production
          script:
            - ./scripts/deploy.sh
      - step:
          name: Smoketest
          deployment: production
          script:
            - |
              curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
                -H "Idempotency-Key: $BITBUCKET_BUILD_NUMBER" \
                --data-urlencode "targetUrl=$DEPLOYMENT_URL" \
                --data-urlencode "commitSha=$BITBUCKET_COMMIT" \
                --data-urlencode "branch=$BITBUCKET_BRANCH" \
                --data-urlencode "externalId=$BITBUCKET_BUILD_NUMBER"

Pull request previews

For preview deployments, set DEPLOYMENT_URL in the deploy step before calling Smoketest. If the URL is computed in a previous step, persist it as an artifact or write the Smoketest call in the same step that deploys.

bitbucket-pipelines.yml
- step:
    name: Deploy preview and run Smoketest
    script:
      - export DEPLOYMENT_URL="https://preview-${BITBUCKET_PR_ID}.example.com"
      - ./scripts/deploy-preview.sh "$DEPLOYMENT_URL"
      - |
        curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
          -H "Idempotency-Key: $BITBUCKET_BUILD_NUMBER-$BITBUCKET_PR_ID" \
          --data-urlencode "targetUrl=$DEPLOYMENT_URL" \
          --data-urlencode "commitSha=$BITBUCKET_COMMIT" \
          --data-urlencode "branch=$BITBUCKET_BRANCH" \
          --data-urlencode "prNumber=$BITBUCKET_PR_ID" \
          --data-urlencode "externalId=$BITBUCKET_BUILD_NUMBER-$BITBUCKET_PR_ID"

On this page