Skip to main content

Working With CicleCI

Configuring the Applitools CI/CD Integration

  1. In the config.yml file in the .circlec folder, add the following command under jobs/build/steps so that it runs before the Eyes test starts:

    jobs:
    build:
    steps:
    - run:
    command: |
    export APPLITOOLS_BATCH_ID=$(echo $CIRCLE_SHA1)
    run_the_test

Preparing For Commit Push Action

If you're triggering a build from commit push actions, the Eyes server must be notified. Here's an example of how to notify the Eyes Server using a curl request:

curl -L -d '' -X POST "$APPLITOOLS_SERVER_URL/api/externals/github/push?
apiKey=$APPLITOOLS_API_KEY&CommitSha=$APPLITOOLS_BATCH_ID&BranchName=${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BRANCH}
&ParentBranchName=<Parent branch name - optional>"

Enabling Applitools logs in CircleCI

To collect Applitools SDK logs in CircleCI, add a job step that sets the log environment variables and store the logs directory as an artifact:

steps:
- run:
name: Run tests
command: npm test
environment:
APPLITOOLS_SHOW_LOGS: "true"
APPLITOOLS_LOG_DIR: "logs"
- store_artifacts:
path: logs
note

If your CircleCI job runs your tests inside Docker, the log files are written inside the container and will be lost when the container stops unless you mount the log folder to the workspace.

Example Docker command:

docker run \
-e APPLITOOLS_SHOW_LOGS=true \
-e APPLITOOLS_LOG_DIR=/usr/src/app/logs \
-v ${WORKSPACE}/applitools-logs:/usr/src/app/logs \
your-image-name

Adjust ${WORKSPACE} to the workspace path used by CircleCI.

  1. In the project dashboard, click the gear icon
  2. On the left menu, under Build Settings, click Environment Variables.
  3. Click Add Variable.
  4. In the Name field enter APPLITOOLS_API_KEY.
  5. In the Value field enter the value of your API key. To obtain the value of your API key, see How to obtain your API key.
  6. Click Add Variable.