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
- In your Bitbucket repository, navigate to:
Repository settings → Repository variables - Click Add variable.
- Add the following secrets:
- Cloudsmith Token
- Name:
CLOUDSMITH_TOKEN - Value: (paste the Cloudsmith token value)
- Name:
- Level CI Project Token
- Name:
LEVEL_CI_TOKEN - Value: (paste the Project token value)
- Name:
- Cloudsmith Token
- 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/cliThis 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:
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 Config4. Update bitbucket-pipelines.yml
Add the Level CI pipe step after your end-to-end (e2e) tests.
# Insert your e2e test execution steps here
- pipe: levelaccess/level-ci-bitbucket:<version>
variables:
USERWAY_TOKEN: $USERWAY_TOKENFor 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:
- Ensure your e2e tests pass locally.
- 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.