Skip to main content
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

View Build reports in Jenkins

Jenkins is a continuous integration tool that enables continuous testing, build, and deployment of iterative code changes. CI/CD tools help catch failures ahead of the production stage and mitigate them as they occur.

Prerequisites

Before you can start integration, ensure that the following tasks are complete.

  • Jenkins CI server (v1.653+) is installed on your machine.
  • Access to the BrowserStack account credentials, namely BrowserStack account credentials.
  • Jenkins server is running locally on the default port http://localhost:8080/, and you have created a pipeline.
  • You are a maintainer or owner of your project repository.
  • Jenkinsfile is created in your project repository. This is required only if you are using the jenkinsfile method.

Install and configure the BrowserStack Jenkins plugin

The BrowserStack Jenkins plugin eases the process of configuring Jenkins to run tests on BrowserStack. This section explains how to:

  1. Install the BrowserStack plugin
  2. Configure your BrowserStack credentials in plugin

After installing and configuring the BrowserStack plugin, you can now integrate Test Reporting & Analytics with Jenkins using either of the following methods:

  • Using the jenkinsfile.
  • Using Post-build actions in Jenkins.

Step 1: Install the BrowserStack Plugin

To install the BrowserStack plugin, complete the following steps:

  1. Go to your Jenkins page, running by default on http://localhost:8080/, and click Manage jenkins in the left navigation bar.
  2. On the System configuration page, click Plugins. A tile named Plugins highlighted in red on a page titled system configuration
  3. Search for BrowserStack in the search box. Image showing page asking user to choose BrowserStack from the list of available plugins
  4. Select BrowserStack and click either Install without restart or Download now and install after restart, depending on your preference.
  5. On the Installing Plugins/Upgrades page, view the installation status of the plugin.
  6. After installation is successful, click Go back to the top page to configure the plugin.

Step 2: Configure BrowserStack credentials in Jenkins

After you’ve installed the plugin, complete the following steps to configure your BrowserStack credentials in the plugin:

  1. On your Jenkins page (http://localhost:8080/), click Manage Jenkins > System.
  2. Under the BrowserStack Credentials section, click Add > Jenkins.
  3. In the Jenkins Credentials Provider: Jenkins window, enter your Username and Access Key.
  4. Click Authenticate. After the plugin verifies your BrowserStack credentials, a Success text appears.
  5. Click Add at the bottom of the Jenkins Credentials Provider: Jenkins window. You will be redirected to the configuration page.
    Image showing screen asking user to click the add button
  6. On the Configuration page, click Save.
  7. On your Jenkins Dashboard, click Manage Jenkins > Credentials.
  8. In the Credentials section, note down the ID of the credential shown in the ID column. This ID will be used in the Jenkinsfile of your project.
    Browserstack credentials on jenkins
  9. In the Jenkinsfile of your project, add the browserstack(credentialsId: '<credential_id>') statement and wrap all the test commands inside it, as follows:
Jenkinsfile
Copy icon Copy

The following sample Jenkinsfile defines the setup stage, credential ID, and a sample shell command:

Jenkinsfile
Copy icon Copy

Integrate BrowserStack TRA with Jenkins using the Jenkinsfile

To integrate BrowserStack with Jenkins using the jenkinsfile, you need to add the BrowserStack plugin to your pipeline script. Here’s an example of how to do this:

pipeline {
    agent any
    stages {
        stage('Test') {
            steps {
                script {
                    browserstack {
                        // Your test commands go here
                    }
                }
            }
        }
    }
}

Integrate existing test cases

With existing test cases, integrating BrowserStack involves editing your test cases to add BrowserStack capabilities, credentials, and remote URL.

Though your existing test scripts include capabilities, BrowserStack expects specific capabilities, such as browser version, etc. that help determine how tests are run. This example code snippet shows the BrowserStack specific capabilities.

Step 1: Set environment variables in test script

The BrowserStack Jenkins plugin sets the following environment variables:

  • BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY: They are set to your BrowserStack Username and Access Key, respectively, when you configure BrowserStack credentials in Jenkins.
  • BROWSERSTACK_BUILD_NAME: It is generated automatically by Jenkins plugin

Use the following example code snippet to set environment variables and capabilities in your website tests:

browserstack.yml
Copy icon Copy

Use the following example code snippet to set environment variables and capabilities in your app tests:

browserstack.yml
Copy icon Copy

Step 2: Add commands in Jenkinsfile to run test

Add commands in your Jenkinsfile to run your test using the following steps:

  1. Go to the Jenkinsfile of your project.
  2. Add the commands and wrap all the test commands inside the browserStack statement, as follows. To run parallel tests, add the command used to run parallel tests.
Jenkinsfile
Copy icon Copy

Step 3: Enable reporting in Jenkins

Enable reporting in Jenkins using the following steps:

  1. Go to the Jenkinsfile of your project.
  2. Add the following code statement after the browserstack block in the Jenkinsfile:
     // Enable reporting in Jenkins
     browserStackReportPublisher 'automate'
    

A sample Jenkinsfile that uses the browserStackReportPublisher 'automate' statement is as follows:

Jenkinsfile
Copy icon Copy

Integrate BrowserStack TRA with Jenkins using post-build actions in Jenkins

In Jenkins, you can set up post-build actions for BrowserStack Report Integration. To do this, complete the following steps:

  1. In Jenkins, click Configure.
  2. In the Post-build Actions section, click Add post-build action.
  3. Select BrowserStack Test Report and Insights. A drop-down menu to select post-build actions including BrowserStack Test Report and Insights

View test reports in Jenkins

The BrowserStack Jenkins plugin enables you to embed the test results from BrowserStack TRA into Jenkins. The report gives an overall summary of the test build and its sessions.

Ensure that you set the build capability to the BROWSERSTACK_BUILD_NAME environment variable in your test script without which the plugin fails to generate and embed reports in Jenkins. Check out the Using Environment variables section to learn about environment variables.

With this integration, you can now view the results of your tests run on BrowserStack within Jenkins.

BrowserStack generated report on Jenkins

Click either View Full BrowserStack Report or BrowserStack Test Report link in the left navigation bar to view the list of test sessions.

View a detailed Test Report on BrowserStack

Selecting any session from this table redirects you to the dashboard where you can view video recording, text logs, and other debugging options for a session.

This plugin also supports integration with the reporting framework in Java - TestNG and JUnit & NodeJS - Protractor and WebdriverIO. Check out the integrate Jenkins with reporting frameworks section to learn about the integration steps.

Rerun failed tests

You can rerun failed tests from the BrowserStack Test Reporting & Analytics dashboard after integrating Jenkins. For more information, refer to rerun failed tests using Jenkins

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