Screenshot capture in GitLab CI pipelines
Automated visual testing for every merge request
Integrate screenshot capture into your GitLab CI/CD pipelines. Capture screenshots of review apps on every merge request, store them as pipeline artifacts, and catch visual issues before merging.
- 1
Add a pipeline stage
Add a screenshots stage to your .gitlab-ci.yml file.
- 2
Store the API key
Add your API key as a GitLab CI/CD variable in project settings.
- 3
Capture screenshots
Use curl to call the Allscreenshots API targeting your review app URL.
- 4
Store as artifacts
Save screenshots as pipeline artifacts for easy access from merge requests.
1stages:
2 - test
3 - screenshots
4
5capture_screenshots:
6 stage: screenshots
7 image: alpine/curl
8 script:
9 - |
10 curl -X POST 'https://api.allscreenshots.com/v1/screenshots' \
11 -H "X-API-Key: $SCREENSHOT_API_KEY" \
12 -H 'Content-Type: application/json' \
13 -d "{
14 \"url\": \"https://$CI_ENVIRONMENT_SLUG.yourapp.com\",
15 \"fullPage\": true,
16 \"viewport\": { \"width\": 1920, \"height\": 1080 }
17 }" -o screenshot.png
18 artifacts:
19 paths:
20 - screenshot.png
21 expire_in: 30 days
22 only:
23 - merge_requestsLightweight CI job
Uses a tiny alpine/curl image. No heavy browser dependencies in your pipeline.
Review app screenshots
Automatically capture screenshots of GitLab review apps for every merge request.
Artifact integration
Screenshots appear as downloadable artifacts directly in your merge request.
Can I use this with GitLab review apps?
Yes. Use the $CI_ENVIRONMENT_SLUG variable to dynamically target your review app URL in the API request.
How do I store the API key in GitLab?
Go to Settings > CI/CD > Variables and add SCREENSHOT_API_KEY as a masked variable.
Can I run screenshots in parallel with tests?
Yes. Place the screenshot job in a separate stage or use the needs keyword to run it in parallel with other jobs.
- Full-page captures
- Popups and repeated sticky bars removed
- Markdown, JSON and PDF output
- Crawl a site from one URL
- Desktop, tablet and phone in one image
- Works in n8n, Make and Zapier
- MCP server for AI assistants