Skip to Content
Get startedStep 3: build environmentBuild environment with Bitbucket

Build environment with Bitbucket

Level CI integrates into your Bitbucket pipelines through a custom pipe. The main purpose of the pipe is to collect accessibility reports generated during e2e tests execution and to trigger analysis via Level CI API.

To build your environment:

1. Add a Repository Variable

  1. In your Bitbucket repository, navigate to:
    Repository settings → Repository variables
  2. Click Add variable.
  3. Add the following secrets:
    • Cloudsmith Token
      • Name: CLOUDSMITH_TOKEN
      • Value: (paste the Cloudsmith token value)
    • Level CI Project Token
      • Name: LEVEL_CI_TOKEN
      • Value: (paste the Project token value)
  4. Click Add.

2. Install the Level CI CLI

Install the @level-ci/cli package in the root of your project:

npm install --save-dev @level-ci/cli

This CLI provides a command-line interface for scans and includes TypeScript types for configuration files.


3. Create a Configuration File

In the root of your project, create a level-ci.config.ts (or .js) file:

level-ci.config.ts
import type { Config } from '@level-ci/cli' export default { organization: 'your_organisation', project: 'your_project', token: process.env.LEVEL_CI_TOKEN, reportPaths: ['./level-ci-reports'], } satisfies Config

4. Update bitbucket-pipelines.yml

Add the Level CI pipe step after your end-to-end (e2e) tests.

bitbucket-pipelines.yml
# Insert your e2e test execution steps here - pipe: levelaccess/level-ci-bitbucket:<version> variables: USERWAY_TOKEN: $USERWAY_TOKEN

For a working example, check out our sample repository. For more information, see the Bitbucket pipe documentation.


5. Verify configuration

Before committing changes, validate the setup locally:

  1. Ensure your e2e tests pass locally.
  2. Run the following command in your terminal:
npx level-ci --verify --token=<your_project_token>

6. Troubleshooting

If you encounter issues, refer to the troubleshooting guide.

Last updated on