Configuring your CI for Bitbucket integration

Once you have setup Bitbucket integration, you need to set up your CI to configure the Eyes SDK with information related to the Bitbucket pull request or commit request. To allow the Eyes Batch to integrate data received from the Bitbucket server, you need to set the following Environment variables:

  • APPLITOOLS_API_KEY - Your API key. To obtain your key see How to obtain your API key.

  • APPLITOOLS_SERVER_URL - The URL of the Eyes server. If you use the public Eyes server, the URL is https://eyes.applitools.com

  • APPLITOOLS_BATCH_ID - The Commit SHA of the current build. This also must be set as an environment variable before running Eyes tests.

  • APPLITOOLS_BATCH_BUILD_ID - (optional) The Bitbucket build ID. This is required if you run multiple builds in parallel on the same commit SHA, for example, parallel push and PR builds of the same source branch. You can obtain the Bitbucket build ID from your CI.

    If you run parallel push and pull requests, you need to disable Automatic Batch Closing, and notify Eyes when a build is complete.

If Eyes cannot recognize the End of Build event, (for example in your CI system, Bitbucket cannot recognize identify an End of Build event, or you have multiple concurrent builds), you also need to add a cURL command to notify Eyes when all builds are complete. For details, see Notifying Eyes when a build is complete.

Below are procedures to set required variables and other required settings in common CIs.

Bitbucket CI

In the Bitbucket configuration file .bitbucket-pipelines.yml, add the following lines:

Copy
script:
    - export APPLITOOLS_API_KEY=<Your Api Key>
    - export APPLITOOLS_SERVER_URL=<Eyes Server URL>
    - export APPLITOOLS_BATCH_ID=$BITBUCKET_COMMIT

$BITBUCKET_COMMIT is the default environment variable for BitBucket commit SHA, which is used with the BitBucket CI/CD.

CircleCI

Build configuration

In the folder .circleci, in the config.yml file, add the following run command under jobs/build/steps before running the visual UI test.

Copy
jobs:
  build:
    steps:
       - run: "export APPLITOOLS_BATCH_ID=`echo $CIRCLE_SHA1`"

Environment variable

  1. In the project dashboard, click the “gear” icon.

  2. In the menu on the left, click Build Settings > Environment variable.

  3. Click Add Variable.

  4. In the Name field, enter the following variables:

    • APPLITOOLS_API_KEY - Your API key. To obtain your key see How to obtain your API key.

    • APPLITOOLS_SERVER_URL - The URL of the Eyes server. If you use the public Eyes server, the URL is https://eyes.applitools.com

AppVeyor

Build configuration

In the appveyor.yml file, add the following line in the init: section:

Copy
init:
  - ps: $env:APPLITOOLS_BATCH_ID = if ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) { $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT } else { $env:APPVEYOR_REPO_COMMIT }

Environment variable

  1. On your project page, click SETTINGS.

  2. On the left panel, select Environment.

  3. In the Environment variables section click Add variable and add the following variables:

    • APPLITOOLS_API_KEY - Your API key. To obtain your key see How to obtain your API key.

    • APPLITOOLS_SERVER_URL - The URL of the Eyes server. If you use the public Eyes server, the URL is https://eyes.applitools.com

  4. Click Save.

Jenkins

Both configuration and setting the environment variable are done by navigating to the Jenkins project configuration, and going to the Execute shell window.

Build configuration

Set the APPLITOOLS_BATCH_ID as follows:

Copy
export APPLITOOLS_BATCH_ID=`echo ${GIT_COMMIT}`

Replace {GIT_COMMIT} with the environment variable you use to store the Commit SHA pull request.

Environment variable

Configure the API key as follows:

Copy
export APPLITOOLS_API_KEY=<Your Api Key>
export APPLITOOLS_SERVER_URL=<Eyes Server URL>