Bitbucket Integration

Setup Guide for integrating Bitbucket with Hypertest


  1. Your repositories are hosted on Bitbucket

  2. Your Bitbucket user account should have your repository

  3. Your CI pipeline is triggered on pull request events. Refer CI Integration

Sample file

A sample CI file for Bitbucket CI can be found below

# This is a basic workflow to help you get started with Bitbucket Pipeline

# This pipeline will only run on pull requests
    '**': # This runs as default for any branch not elsewhere defined
      # Job to build application
      - step:
          name: Build
            - echo "This job builds your application"
            - echo "Add other actions to build"
      # Job to test application
      - step:
          name: Test
            - echo "This job tests your application"
            - echo "Add other actions to test"
      # Job to deploy application
      - step:
          name: Test
            - echo "This job deploys your application"
            - echo "Add other actions to deploy"
       # Job to download HyperTest CLI and then start a new test from CLI   
      - step:
            - echo "This job downloads HyperTest Cli and start a new test"
            - export HT_BASE_URL='http://<hypertest-vm-ip>:<dashboard-port>'
            - export HT_PR=$BITBUCKET_PR_ID
            - export HT_API_TOKEN='<your api token>' # required only for k8s based HT Setup, not required for linux based HT Setup
            ## Read below documentation for these Variables, if you are passing variables here you don't need to do Step 3
            - export BITBUCKET_CONFIG_WORKSPACE='<bitbucket-workspace>'
            - export BITBUCKET_CONFIG_REPO_SLUG='<bitbucket repo name>' 
            - export BITBUCKET_CONFIG_USER_NAME='<bitbucket user-name>'
            - export BITBUCKET_CONFIG_APP_PASSWORD='<bitbucket app-password>'
            - printenv|sort
            - wget -O ht-cli.tar.xz
            - tar xvf ht-cli.tar.xz
            - ./hypertest can-run-test
            - ./hypertest start-new-test

Steps to integrate Bitbucket

1. Create an app password

HyperTest will add comments on the merge request discussions. We recommend you create a new user in bitbucket and add to your repo for this. You can however use an existing user as well.

  1. The required scope for password is Pull requests

  2. Create the app password with large expiration time (like 10 years)

2. Copy Bitbucket workspace

A workspace is where you will create repositories, collaborate on your code. Below is how the URLs will be formatted for any repositories you create in your workspace:<workspace name>/<repo name>

3. Update Hypertest Configuration

To publish reports on your CI, we need to provide above your bitbucket repo info and access to it etc to HyperTest. You can either add it is a configuration in HyperTest Dashboard's Service Configuration or pass it as environment variable in your CI, while starting a test.

If you have already passed the Bitbucket confirguration such as workspace, repo name etc in your CI file, you don't need to do this Step 3.

Below is example for both

a. HyperTest's Dashboard Configuration

This can be done by navigating to the Settings page in HyperTest Dashboard. Click on Service Configuration and copy-paste the below parameters and edit the value's accordingly. Click on update after you have added.

  WORKSPACE: <bitbucket-workspace>
  REPO_SLUG: <bitbucket repo name>
  USER_NAME: <bitbucket user-name>
  APP_PASSWORD: <bitbucket app-password>

Click on "Update" and you have successfully integrated Bitbucket with HyperTest.

b. Add the below enviornment variables in your CI pipeline

See details in bitbucket CI file above on how to set them

BITBUCKET_CONFIG_REPO_SLUG='<bitbucket repo name>' 
BITBUCKET_CONFIG_USER_NAME='<bitbucket user-name>'
BITBUCKET_CONFIG_APP_PASSWORD='<bitbucket app-password>'

Now every time your CI(Bitbucket or other CI tools) triggers a test through HyperTest CLI, HyperTest will add Check reports to your merge request like below.

By default, checks will be in a failed state in order for you to read the HyperTest Report.

Last updated