Bitbucket Pipelines CI/CD with BrowserStack Load Testing
Integrate BrowserStack Load Testing into Bitbucket Pipelines to run load tests in your Bitbucket-hosted CI/CD workflows.
You can add BrowserStack Load Testing to your Bitbucket Pipelines so that every push triggers a load test.
Prerequisites
Make sure you have the following before you start:
- A BrowserStack account with access to Load Testing.
- A Bitbucket Cloud workspace and repository on the Free or paid plan. Pipelines is enabled per repository.
- Bitbucket repository variables for your BrowserStack credentials. You can find the credentials on your account’s profile page:
-
BROWSERSTACK_USERNAME: Your BrowserStack username. -
BROWSERSTACK_ACCESS_KEY: Your BrowserStack access key.
-
To add the variables:
- Go to your repository on Bitbucket Cloud.
- In the left sidebar, click the gear icon → Repository settings.
- Under PIPELINES, click Repository variables.
- For each of the two credentials, click Add, set the Name and Value, mark Secured to mask the value in logs, and click Add.
To enable Pipelines (if not already enabled):
- Repository settings → PIPELINES → Settings.
- Toggle Enable Pipelines on.
Bitbucket automatically injects these variables as environment variables into every pipeline step.
Bitbucket Pipelines configuration
Use the following Bitbucket Pipelines configuration to download the BrowserStack CLI, run a sample Playwright-based load test, and upload JUnit XML reports as a pipeline artifact. Save it at the repository root as bitbucket-pipelines.yml.
image: atlassian/default-image:4
pipelines:
default:
- step:
name: Load Test
script:
- echo "Running unit tests"
- |
: "${BROWSERSTACK_USERNAME:?set BROWSERSTACK_USERNAME as a Secured repository variable}"
: "${BROWSERSTACK_ACCESS_KEY:?set BROWSERSTACK_ACCESS_KEY as a Secured repository variable}"
export BROWSERSTACK_USERNAME BROWSERSTACK_ACCESS_KEY
- |
OS=$(uname -s); ARCH=$(uname -m)
[ "$OS" = "Darwin" ] && OS=macos || OS=linux
case "$ARCH" in *arm*) ARCH=arm64 ;; *) ARCH=x64 ;; esac
curl -fL "https://load-api.browserstack.com/api/v1/binary?os=${OS}&arch=${ARCH}" -o browserstack-cli.zip
unzip -oq browserstack-cli.zip
chmod +x browserstack-cli
- |
curl -L https://github.com/browserstack/browserstack-playwright-load-testing-sample/archive/refs/heads/CI/CD-Sample-Playwright.tar.gz \
| tar -xz --strip-components=1
- ./browserstack-cli load run
artifacts:
- reports-*/browserstack-load-test-report-*.xml
Result
When this pipeline runs, it:
- Downloads the BrowserStack CLI for the current runner OS and architecture.
- Fetches the BrowserStack Playwright load-testing sample project.
- Starts a BrowserStack Load Testing run using your BrowserStack credentials.
- Uploads the generated JUnit XML reports as pipeline artifacts available in the Bitbucket UI.
Notes
- Free workspace plan grants approximately 50 build minutes per month; sufficient for a few validation runs.
- The
bitbucket-pipelines.ymlfilename is required; Bitbucket silently ignores a file with any other name or location. - The
atlassian/default-image:4runs Linux x64. For other architectures or self-hosted runners, define a custom Pipelines runner. - Bitbucket’s Repository variables are scoped per repository. To share variables across multiple repositories in the same workspace, use Workspace variables under workspace settings instead.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!