Skip to main content
🚀 Self Healing AI Agent now live in App Automate! Auto-fix flaky tests instantly with zero code changes. Enable now!
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Integrate your Appium test suite with Bitbucket Pipelines

Integrate Bitbucket Pipelines with the BrowserStack real device cloud to run your Appium tests on App Automate.

You can run your automated tests on BrowserStack App Automate using your existing Bitbucket Pipelines setup. Bitbucket Pipelines reads its configuration from bitbucket-pipelines.yml, and you use the same file to run your tests on BrowserStack.

Prerequisites

Before you begin, ensure that you have the following:

  • A Bitbucket Cloud repository with Pipelines enabled and a bitbucket-pipelines.yml file.
  • An Appium test suite for your Android (.apk or .aab) or iOS (.ipa) app.
  • Your BrowserStack username and access key, available on the Account Settings page.

Integration steps

To integrate your Appium test suite with Bitbucket Pipelines, complete the following steps:

Set up test environment

Update your bitbucket-pipelines.yml file. Each of the following example configurations installs your project dependencies, uploads your app to BrowserStack, and runs your tests. The pipeline reads your credentials from the BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY repository variables, which you add in Step 3, Set BrowserStack credentials. Select your language to view the example:

bitbucket-pipelines.yml
Copy icon Copy

Upload your app to BrowserStack

Your tests need the app_url of the app you want to test. The app_url has the format bs://<hash>. On every run, the example pipeline in the previous step uses the REST API to upload your app with the custom ID SampleApp and exports the returned app_url as the BROWSERSTACK_APP_ID environment variable. A custom ID always refers to the latest app uploaded with that ID.

If your app doesn’t change between runs, upload it once and remove the upload command from bitbucket-pipelines.yml. If you use the BrowserStack SDK, set app in browserstack.yml to the returned app_url or custom ID. Otherwise, add the app_url or custom ID as the BROWSERSTACK_APP_ID repository variable.

Upload your Android .apk or .aab file, or iOS .ipa file, using one of the following methods:

On the App Automate dashboard, click Upload in the top-right corner. From your filesystem, select the app you want to upload.

Upload button in the top-right corner of the App Automate dashboard

To upload an app using the App Management UI, follow these steps:

  1. On the App Automate dashboard sidebar, click App Management.
  2. In the App Management UI, click Upload App.
  3. From your filesystem, select the app you want to upload. To upload the app using a public URL, paste the URL of your app in the or upload from URL box.
  4. Choose the App Automate framework you want to use for testing. Optionally, add flags and a custom ID.
  5. Click Upload. BrowserStack uploads the app and returns an app_url that you can use to run tests.

Upload App dialog in the App Management UI with filesystem and public URL options

To manage your apps, see Manage apps using App Management UI.

To upload an app from your filesystem using the REST API, run the following cURL command:

Terminal
Copy icon Copy

Set BrowserStack credentials

Saving your BrowserStack credentials as environment variables lets you run your test suite from your local or CI environment. It also keeps your credentials out of your code and repositories. If you already set these as environment variables on your local machine, skip the local setup below.

In your Bitbucket repository, go to Repository settings > Pipelines > Repository variables and add the following variables:

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

To run the same tests from your local machine, set the credentials as environment variables using the following commands:

Copy icon Copy

Configure your tests to use these variables:

browserstack.yml
Copy icon Copy

When the BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY environment variables are set, the BrowserStack SDK uses them instead of the userName and accessKey values in browserstack.yml. Set app to the custom ID from the upload step so that the SDK always tests the latest upload.

Integrate test cases for apps that access privately hosted servers

If your app accesses servers hosted locally, in a staging environment, or behind a firewall, set up Local Testing so that BrowserStack can reach them.

Enable Local Testing in your pipeline using one of the following methods:

If you prefer to manage the Local connection through the BrowserStack SDK, add the following options to your browserstack.yml file:

browserstack.yml
Copy icon Copy

You can also set other Local options, such as proxy settings or multiple Local connections. For more information, see Test in local environments with Appium.

If you use the Local binary or language bindings, add the local capability to your test scripts. When you set this capability to true, BrowserStack routes your test traffic through the Local binary running in your network. If you use the BrowserStack SDK, browserstackLocal: true in browserstack.yml already sets this capability.

browserstackOptions.put("local", "true");

View test results

After you push a commit, Bitbucket Pipelines runs your tests on BrowserStack App Automate as configured in bitbucket-pipelines.yml.

In your Bitbucket repository, click Pipelines to check whether the test suite passed or failed.

Bitbucket Pipelines page showing the status of each pipeline run

After the pipeline completes, view the triggered build on the App Automate dashboard.

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