Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Run Tests with Bitbucket Pipelines

A step-by-step guide to help you integrate Bitbucket Pipelines with the BrowserStack device cloud for running all your Selenium tests on BrowserStack Automate.

You can run your automated tests on BrowserStack Automate using your existing Bitbucket pipelines setup. Bitbucket Pipelines uses bitbucket-pipelines.yml for configuration, and the same can be used to run your tests on BrowserStack too.

To run your tests, there are three things that we recommend you to do:

  1. Setup your environment as per your testing needs
  2. Set your BrowserStack authentication details as environment variables and read them in your tests
  3. Integrate test cases for privately hosted websites

Set up test environment

You can simply update your bitbucket-pipelines.yml as per your needs. Here is an example configuration for your reference:

bitbucket-pipeline.yml
image: maven:3.3.9
pipelines:
  default:
    - step:
        script:
          - mvn clean
          - mvn test # Your test runner command to run the tests

The above example is for a Java based test suite, for more languages refer to Use Pipelines in different software languages page.

Set up environment variables

If you are already using environment variables to specify your BrowserStack authentication details, you can skip this step.

If not, we strongly recommend you not to hardcode the auth details in your code (and hence do not commit and check-in your auth keys into code repositories). This helps in both maintaining a secure codebase, as well as helping you flexibly run your tests using different service accounts based on your needs (for example, run pre-prod regression suites using a team account with higher parallels limit).

Go to your Bitbucket repository’s settings and add the following environment variables:

  • BROWSERSTACK_USERNAME: Your BrowserStack username
  • BROWSERSTACK_ACCESS_KEY: Your BrowserStack access key

You can then read these variables in your tests. Here is a sample code to demonstrate how that’s done:

browserstack.yml
Copy icon Copy

Integrate test cases for privately hosted websites

If you are testing websites hosted locally as part of your testing or development environment, configure your bitbucket-pipelines.yml file to use the BrowserStack Local binary and route your tests through the local server.

Enable Local Testing

If you prefer to manage the Local connection through the BrowserStack SDK you can add the capability in the browserstack.yml file.

browserstack.yml
Copy icon Copy

Apart from these configurations, you can set other Local options, such as, testing behind a proxy, folder testing, or using multiple local instances. Check out Introduction to Local Testing for more information.

Add the local capability to test scripts

Add the local capability to test scripts using the following code snippets. When you set this capability to true, BrowserStack resolves the request via the Local agent running in your network.

browserstack.yml
Copy icon Copy

And that’s all! You are now all set to run your tests automatically on BrowserStack Automate on every PR or commit as per your workflows.

You can verify if the test suite passed or failed by clicking Pipelines in your repository as shown in the following image. Check build status

Once the pipeline has completed execution you will be able to check the triggered build on the Automate dashboard as well.

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