Configuring your CI for the Eyes/GitHub integration

The article Using Eyes with GitHub describes configurations that need to be set up in the Test Manager to use Eyes with GitHub. The current article describes the configuration that needs to be set up in the CI system you use with GitHub. The configuration consists of two steps:

  • Setting up the start of the build : Setup that is done by the CI as part of the build before Eyes tests are executed. This sets environment variables that are read by the Eyes SDK to obtain the information required by Eyes to execute the test.
  • Synchronizing multiple concurrent builds : If the CI runs a build using multiple concurrent instances, then it needs to notify Eyes when all of the instances have terminated.

Setting up the start of the build

Eyes needs two values in order to run the visual tests in the builds:

  • Your Eyes API Key : This is passed by setting the environment variable APPLITOOLS_API_KEY to the value of your Eyes API key. To obtain the value of your Eyes API key, see How to retrieve your API key .
  • The batch ID : In a standalone Eyes test, the result of each test execution appears in a separate batch in the Test manager. When multiple Eyes tests are executed using a supported CI, all of the test results appear together in a single batch. The batch ID is the Git Commit Id (SHA) and is passed to Eyes in the APPLITOOLS_BATCH_ID variable.

For detailed configuration instructions for your CI, click on the relevant link below:

How to prepare your code

The configuration described in the previous section sets up the values of the environment variables APPLITOOLS_API_KEY and APPLITOOLS_BATCH_ID to provide the API key and batch ID respectively. Recent versions of the Eyes SDK read these environment variables to obtain this information.

How to prepare your code for a commit push action

You need to add an API call to the CI script that will inform Applitools each time there is a commit push action.

curl -L -d '' -X POST "$APPLITOOLS_SERVER_URL/api/externals/github/push?
  • GITHUB_BRANCH represents the full GitHub branch name, including the organization, the repository, and the branch in the format my-org/my-repo/my-branch . For example in Circle CI:


  • ParentBranchName is optional. The default is the main branch of the repository.

  • The APPLITOOLS_API_KEY argument must be passed in the query and cannot be passed in the body. For example:<myApiKe> .)

Synchronizing multiple concurrent builds

By setting the APPLITOOLS_BATCH_ID environment variable, as described in the previous section, you instruct Eyes to put the results of all tests in a particular CI build in the same Test manager batch. If your CI runs multiple builds concurrently , then you need to follow two more steps:

  • In the GitHub integration page of the Test manager, follow the instructions to disable automatic batch closing described in Using Eyes with GitHub . This is a one-time configuration that needs to be done by each team for each repository that has concurrent builds.

  • You need to indicate to Eyes when all of the concurrent builds have completed. You do this by sending the Eyes server an HTTP command. How you do this depends on your environment. For example, on a Linux-based system, you can do it as follows:

    eyesserver=""  # set this to your Eyes server name.
    githubserver="your_gituhub_server"   # as entered in the Eyes/github integration screen e.g.
    batchid=$APPLITOOLS_BATCH_ID         # this was previously set to the Commit SHA    
    header="Content-Type: application/json --data `{\"serverId\": \"$githubserver", \"commitSha\": \"$batchid\"}`"    
    extraInfo="-H $header  -v -L"

    curl -X POST $url $extraInfo

    Note that various values represented here as "$xxxx" are values set in other parts of the integration:

    • $eyesserver : The URL of your Eyes server - the same value that you set when defining the Eyes server when you run visual Eyes tests (or the default shown in the snippet above).
    • $githubserver : The GitHub server you entered on the Eyes/GitHub integration screen. as described in Using Eyes with GitHub .
    • $apikey : The same API key you use when running visual Eyes tests.
    • $batchid : The unique value that defines the batch. It is the value assigned to the APPLITOOLS_BATCH_ID environment variable, as described in Setting up the start of the build above.