Setting up Screenshotbot for Jenkins

Once you have started using one of the common Screenshot Testing libraries, integrating with Jenkins should be just a few lines of code in your Pipeline.

Preparing Your Screenshots

Screenshotbot does not require you to make API calls during your test. But you will need to store your screenshots generated during the run into a directory, which will be given as input to the Screenshotbot SDK. This directory would consist of PNG files that would be generated in the current run.

The SDK would handle most of the common integrations, but we will need to give it specific instructions depending on the layout of your screenshots.

We have special integrations for screenshot-tests-for-android and for swift-snapshot-testing, please consult those pages for the right arguments to pass to the SDK.

Fetching the SDK

In your Pipeline, run the following command to fetch the SDK:

curl https://screenshotbot.io/recorder.sh | sh

This script has no dependencies and will install the correct version of the SDK into the directory ~/screenshotbot/. If you aren't using Docker you can install this once and reuse the installed script to speed up your pipelines.

API Keys

Screenshot needs API keys to access your account. You can either store this in ~/.screenshotbot on your workers.

{
    "api_key": "<api-key>",
    "api_secret": "<api-secret>"
}

Uploading Screenshots with the SDK

The recorder script will be invoked to upload the Screenshots. We need some additional information about the commits for Screenshotbot to be able to process the change and do the right action. For instance, if you are using GitHub, and this job is for a Pull Request, you can provide --pull-request <pull-request-url>. This would ensure we know where to comment with the updates. For a full list of arguments, see recorder.