Bitbucket Pipelines
Trigger Smoketest deployment webhooks from Bitbucket Pipelines after a deploy step.
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
- Create a deployment webhook in Smoketest.
- Add
SMOKETEST_DEPLOYMENT_WEBHOOK_URLas a secured repository or deployment variable. - Add
DEPLOYMENT_URLas a deployment variable for each Bitbucket deployment environment.
Pipeline example
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.
- 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"