Jenkins + GitHub – Manual Single-File Integration
This guide shows how to run the Early Agent inside a Jenkins pipeline for a GitHub repository, generating tests for a single file using the generate-for-project command.
This workflow is intended for initial integration and validation, before enabling automated commit- or PR-based test generation.
🎯 Goal of This Phase
The purpose of this setup is to:
- Validate Jenkins configuration and credentials
- Ensure Early can run successfully in your environment
- Confirm test generation works end-to-end
- Avoid introducing automation too early in the process
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 Jenkins (for example, via a parameterized or manually started job).
🛠️ Example Jenkinsfile
Below is a declarative Jenkins pipeline for manual, single-file integration:
pipeline {
agent {
docker {
image 'node:22'
args '-u root'
}
}
environment {
API_KEY = credentials('EARLY_SECRET_TOKEN')
TOKEN = credentials('GITHUB_TOKEN')
SCM_PROVIDER = 'github'
TARGET_DIRECTORY = 'src/path/to/file.ts'
REF_NAME = "${env.BRANCH_NAME}"
GIT_USER_EMAIL = credentials('GIT_USER_EMAIL')
NODE_OPTIONS = '--max-old-space-size=5120'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Setup npm auth') {
steps {
sh '''
echo "//npm.pkg.github.com/:_authToken=${TOKEN}" >> ~/.npmrc
echo "@earlyai:registry=https://npm.pkg.github.com" >> ~/.npmrc
'''
}
}
stage('Install dependencies') {
steps {
sh 'npm clean-install'
}
}
stage('Run Early (Single File)') {
steps {
sh '''
npx @earlyai/cli generate-for-project
'''
}
}
}
}
🔐 Required Jenkins Credentials
This example assumes the following credentials are configured in Jenkins:
EARLY_SECRET_TOKEN– Early API keyGITHUB_TOKEN– GitHub token with repository accessGIT_USER_EMAIL– Email address used for committing generated tests
✅ 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 Jenkins job completes without errors
- Logs show coverage analysis and test generation steps
Once validated, you can safely move on to automated workflows.
🔁 Next Step
Proceed to Phase 2 and enable automated test generation on commits:
This guide follows the general Integration Guide and adapts it specifically for Jenkins and GitHub.