Running Tests With a Pipeline Script
This guide provides detailed instructions on utilizing the BitBar Run-in-Cloud plugin within a Pipeline script (Jenkinsfile). For guidance on utilizing the UI build step within the same plugin, refer to Running Tests via the Jenkins Plugin UI.
Credentials Setup
Before you begin using the Pipeline plugin, it's essential to integrate your BitBar API key into Jenkins. To accomplish this, navigate to the Jenkins main page and follow these steps:
Navigate to Credentials > System > Global credentials > Add Credentials.
Select BitBar API key from the Kind dropdown.
Enter your API key and ID.
Click Enter.
Pipeline Script - Snippet Generator
There is a convenient Jenkins Pipeline Snippet Generator similar to the one that is used in the Jenkins Freestyle Project:
Create New Item. Choose Pipeline.
Navigate to Configure.
Click Pipeline Syntax.
Choose Sample Step > runInCloud: Start a run in BitBar Cloud.
Set up parameters like in the
Freestyle project
.Use the generated snippet in your pipeline.
Pipeline Script - Simple Use Case
Explore further details about all potential parameters below. Note that the example provided is not a complete Jenkins file; it is merely a snippet.
stage('Device tests') { steps { runInCloud( // parameters to start test with... cloudUrl: "https://cloud.bitbar.com", credentialsId: "my-bitbar-cloud-credentials-01", projectId: "12345", deviceGroupId: "110", appPath: "/path/to/app.apk", testPath: "/path/to/tests.zip", frameworkId: 252, biometricInstrumentation: true, // ... don't just start test, also wait for results! waitForResultsBlock: [ downloadScreenshots: true, forceFinishAfterBreak: true resultsPath: 'results', hookURL: "url_string_example", testRunStateCheckMethod: 'API_CALL', waitForResultsTimeout: 60 ] ) } }
Parameters
Explore the table below to discover the parameters you can customize for your runInCloud()
method.
Parameter Name | Value Type | Description |
---|---|---|
| String | The absolute or workspace relative path to the app executable ( |
| Boolean | Specifies whether to enable instrumentation on the app in order to bypass biometric authentication during testing. Value is set to false when parameters do not pass. |
| String | The BitBar Cloud URL this run should target. For example, |
| String | The login credentials ID for the BitBar Cloud, which is your API Key. |
| String | The absolute or workspace-relative path to a |
| String | Required. Used to specify which device(s) the test run will target. It's a number that you can find by visiting |
| Boolean | Specifies whether or not to download the screenshots (if any) after the test run completes. The default value: This parameter should be placed within the |
| Boolean | Specifies whether the This parameter is unrelated to the success or failure of tests conducted in the cloud; its sole purpose is to determine whether the step executes without issues or encounters exceptions. |
| Boolean | Whether or not to abort the BitBar Cloud run after waiting for the results for a set amount of time after the run started. If set to This parameter should be placed within the |
| Integer | A parameter used to specify the framework in which you want to execute your test. This parameter allows you to indicate the specific testing framework or environment that your tests should utilize. You can obtain a list of all available https://cloud.bitbar.com/cloud/api/v2/ users/{userId}/available-frameworks Replace |
| String | The URL to which the BitBar Cloud will send a POST request when the test run finishes. Ensure that the address is accessible by the global internet or included in the BitBar Cloud allow list. This can be used by enterprise systems that need to react to completed test runs. For example, This parameter should be placed within the The default value: JENKINS_URL/plugin/ testdroid~run~in~cloud/api/ json/cloud~webhook This default value can be used if The data sent in the POST request is a short UTF-8 snippet in the following format:
|
| String | Additional environment variables provided to the test run. This can be used for advanced logic in test cases where the test might behave differently depending on some value. Key-value pairs should be semicolon-separated ( For example, The default value: empty string. |
| String | The locale (language) that should be set on the phone when the run starts. Has to be a locale supported by Android. For example, The default value: Androids only. |
| String | Required. Defines which BitBar Cloud project this test run should be included in. By extension, this also selects the target platform, Android/iOS. This value is a number that you can find by going to Projects in the BitBar Cloud and reading the URL when you select a project. For instance, if the URL in the browser is For example, |
| String | The absolute or workspace-relative path to a folder where results should be downloaded after the run completes. For example, The default value: Jenkins workspace. This parameter should be placed within the |
| String | Defines in what order tests should be run in the BitBar Cloud, in case multiple devices are targeted. Possible values:
|
| String | The location on the device from where test screenshots should be pulled after a test run. For example, The default value: Androids only. |
| String | The value specifies a way (package/class) to narrow down the test cases that should be run. This parameter applies only to projects of the Android Instrumentation type - Espresso tests. Possible values:
Androids only. Requires |
| String | If For example, An example of a class that might be defined in your tests. |
| String | The absolute or workspace-relative path to a test package that should be uploaded and run in the BitBar Cloud. Most often, a For example, The default value: use the latest test package that was uploaded to this project. |
| String | Custom name for the test run in the BitBar Cloud. For example, By default, the cloud will assign a name like |
| String | The test runner class that will execute Espresso tests. Refer to InstrumentationTestRunner for details. For example, The default value: Androids only. |
| String | Specifies the method by which the plugin will check if the BitBar Cloud run has finished. Possible values:
This parameter should be placed within the |
| String | A value in seconds, how long the cloud test can run before it is forced to shut down. For example, The default value: |
| Array | In a pipeline script, this parameter functions similarly to The following parameters need to be included within
|
| String | A value in seconds specifies how long the build step should wait for cloud results. For example, This parameter should be placed within the |
| String | Runs only test cases that have a certain Java annotation specified. This parameter applies only to projects of the Android Instrumentation type - Espresso tests. For example, Androids only. |
| String | Does not run test cases that have a certain Java annotation specified. This parameter applies only to projects of the Android Instrumentation type - Espresso tests. For example, Androids only. |