Skip to main content
The Stably CLI can run in any CI/CD environment, not just GitHub Actions. This guide covers how to authenticate and run tests using environment variables, making it easy to integrate with GitHub Actions, GitLab CI, CircleCI, Jenkins, Bitbucket Pipelines, and other CI systems.

Authentication for CI

In CI environments, authentication is handled through environment variables instead of interactive browser login. You must set two environment variables:
STABLY_API_KEY
string
required
Your Stably API key. Get it from the API Keys settings page.
STABLY_PROJECT_ID
string
required
Your Stably project ID. Find it in your Stably dashboard project settings or URL.
Never hardcode your API key in configuration files or commit it to version control. Always use your CI provider’s secret management features.

Setup Instructions

1

Get Your API Key

Go to the API Keys settings page and create or copy your API key.
2

Find Your Project ID

Navigate to your project in the Stably dashboard. The project ID is visible in the project settings or in the URL.
3

Configure CI Secrets

Add STABLY_API_KEY and STABLY_PROJECT_ID as secrets in your CI provider’s settings.
4

Run CLI Commands

Use the Stably CLI in your CI pipeline. The CLI automatically uses the environment variables for authentication.

Basic Usage

Once the environment variables are set, you can run any Stably CLI command without interactive authentication. Stably is fully Playwright compatible — all Playwright CLI options are supported:

Loading Test Variables in CI

Use the --env flag to load variables from a named Environment stored in Stably. This avoids managing .env files or duplicating secrets across CI providers.
Instead of adding each secret to your CI provider individually, upload your .env file to a Stably Environment via Bulk Import. The only CI secret you need to configure is STABLY_API_KEY — when credentials rotate, update them once in Stably and every pipeline picks up the change automatically. See Bulk Import for details.
--env is a global option — it must go before the subcommand, with a space (not =):
You can also load from a local .env file committed to your repo (for non-sensitive values):
For all available CLI options and configuration, see the Stably CLI documentation.

CI Platform Examples

GitHub Actions

.github/workflows/stably.yml
If you’re using GitHub Actions and want a simpler setup with cloud execution, consider using the Stably GitHub Action instead.

GitLab CI

.gitlab-ci.yml
In GitLab, add STABLY_API_KEY and STABLY_PROJECT_ID as CI/CD variables in Settings > CI/CD > Variables. Mark them as Protected and Masked for security.

CircleCI

.circleci/config.yml
Add STABLY_API_KEY and STABLY_PROJECT_ID in CircleCI under Project Settings > Environment Variables. Project-level environment variables are automatically available to all jobs — no need to redeclare them in the config file.

Jenkins

Jenkinsfile
Store credentials in Jenkins using Manage Jenkins > Credentials.

Bitbucket Pipelines

bitbucket-pipelines.yml
Add STABLY_API_KEY and STABLY_PROJECT_ID as Repository variables in Repository settings > Pipelines > Repository variables.

Azure DevOps

azure-pipelines.yml
Add the variables in Azure DevOps under Pipelines > Library or as pipeline variables.

Troubleshooting

Verify that both STABLY_API_KEY and STABLY_PROJECT_ID are correctly set:
Ensure the API key is valid and hasn’t expired.
Make sure browsers are installed in your CI environment:
CI environments may be slower than local machines. Increase timeouts:
Or configure timeouts in playwright.config.ts.