CircleCI + Bitbucket β Manual Single-File Integration
This guide shows how to run the Early Agent inside a CircleCI pipeline for a Bitbucket repository, generating tests for a single file using the generate-for-project command.
This workflow is designed for initial integration and validation before enabling automated PR or commit-based test generation.
π― Goal of This Phaseβ
The purpose of this setup is to:
- Validate CI configuration and permissions
- Ensure Early can run successfully in your environment
- Confirm test generation works end-to-end
- Avoid introducing automation too early
Test generation is intentionally scoped to one medium-sized file
(not too small to be trivial, and not too large to complicate validation).
π§© How It Worksβ
At a high level, this pipeline:
- Checks out the repository
- Configures npm authentication
- Installs project dependencies
- Sets required environment variables
- Runs
early generate-for-projecton a single file - Commits generated tests to the specified branch
Execution is manually triggered from CircleCI.
π οΈ Example CircleCI Configurationβ
Below is a complete CircleCI configuration for manual, single-file integration:
version: 2.1
jobs:
earlyai-single-file-integration:
docker:
- image: cimg/node:22.19
steps:
- checkout
- run:
name: Setup npm auth
command: |
echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> ~/.npmrc
echo "@earlyai:registry=https://npm.pkg.github.com" >> ~/.npmrc
- run:
name: Install dependencies
command: npm clean-install
- run:
name: Setup environment variables and run Early
no_output_timeout: 30m
command: |
export API_KEY="$EARLY_SECRET_TOKEN"
export TOKEN="$BB_ACCESS_TOKEN"
export SCM_PROVIDER="bitbucket"
export TARGET_DIRECTORY="src/path/to/file.ts"
export REF_NAME="$CIRCLE_BRANCH"
export GIT_USER_EMAIL="${BB_USER_EMAIL}"
export NODE_OPTIONS="--max-old-space-size=5120"
npx @earlyai/cli generate-for-project
workflows:
earlyai-manual-integration:
jobs:
- earlyai-single-file-integration:
context: early-ci
π Required Secrets & Contextβ
This example assumes the following environment variables are provided via a CircleCI context or project settings:
EARLY_SECRET_TOKENβ Early API keyBB_ACCESS_TOKENβ Bitbucket access tokenBB_USER_EMAILβ Email used for commitsGITHUB_TOKENβ Token for accessing Earlyβs npm package
β Success Criteriaβ
This phase is considered successful when:
- Test files are generated for the selected file
- Generated tests are committed to the target branch
- The pipeline completes without errors
- Logs show coverage analysis and test generation steps
Once validated, you can safely move on to automated PR-based workflows.
π Next Stepβ
Proceed to Phase 2 and enable automated test generation:
This guide follows the general Integration Guide and adapts it specifically for CircleCI and Bitbucket.