Skip to main content
No Result Found
Connect and get help from 7,000+ developers on our Discord community. Ask the CommunityAsk the Community

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:

  1. Go to your repository on Bitbucket Cloud.
  2. In the left sidebar, click the gear icon → Repository settings.
  3. Under PIPELINES, click Repository variables.
  4. 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):

  1. Repository settings → PIPELINES → Settings.
  2. 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.yml filename is required; Bitbucket silently ignores a file with any other name or location.
  • The atlassian/default-image:4 runs 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





Thank you for your valuable feedback

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy Check Circle