Jenkins Integration Setup Guide
This guide walks you through connecting Lathe Studio to Jenkins for CI/CD pipeline integration.
Prerequisites#
- Jenkins instance (2.0+)
- Jenkins job/build pipeline configured
- Project admin access in Lathe Studio
- Jenkins plugins: "Webhook Step" or "HTTP Request" plugin
Overview#
The Jenkins integration enables:
- CI/CD Webhooks: Automatically create builds when Jenkins jobs complete
- Build Status Sync: Track Jenkins build status in Lathe Studio
- Parameterized Builds: Pass test parameters from Lathe Studio to Jenkins
Connecting Jenkins#
Step 1: Create an API Key
- Go to Settings > Organization > API Keys
- Click Create API Key
- Give it a name (e.g., "Jenkins CI")
- Select scopes:
builds:read- View buildsbuilds:create- Create new builds
- Copy the generated key (shown only once)
Step 2: Configure Jenkins Webhook
Option A: Using Jenkinsfile (Recommended)
Add to your Jenkinsfile:
pipeline { agent any stages { stage('Build') { steps { // Your build steps } } stage('Test') { steps { // Your test steps } } } post { always { script { def payload = """ { "build": { "number": ${env.BUILD_NUMBER}, "phase": "COMPLETED", "status": "${currentBuild.currentResult}", "url": "${env.BUILD_URL}" }, "project": { "name": "${env.JOB_NAME}", "url": "${env.JOB_URL}" }, "scm": { "branch": "${env.GIT_BRANCH ?: 'unknown'}", "commit": "${env.GIT_COMMIT ?: 'unknown'}" } } """ httpRequest( url: 'https://lathestudio.dev/api/webhooks/jenkins', httpMode: 'POST', contentType: 'APPLICATION_JSON', requestBody: payload, customHeaders: [ [name: 'Authorization', value: "Bearer ${env.PT_API_KEY}"] ] ) } } } }
Option B: Using Job Configuration
- In Jenkins, go to your job
- Click Configure
- Scroll to Post-build Actions
- Add HTTP Request action:
- URL:
https://lathestudio.dev/api/webhooks/jenkins - HTTP Method: POST
- Content Type: Application JSON
- Request Body: Build payload (see below)
- Custom Headers:
Authorization: Bearer <your-api-key>
- URL:
Step 3: Add API Key to Jenkins Credentials
- Go to Manage Jenkins > Manage Credentials
- Select the appropriate domain
- Click Add Credentials
- Choose Secret text
- Enter your API key as the secret
- ID:
pt-api-key - Click OK
Step 4: Test the Integration
- Run a Jenkins build
- Go to Releases page in Lathe Studio
- You should see the build in the Build Queue section
- Assign it to a release
Authentication Methods#
Method 1: API Key (Recommended)
Include the API key in the Authorization header:
Authorization: Bearer pt_live_xxxxxxxxxxxxxxxx
Method 2: Organization ID
Include your organization ID in a custom header:
X-Pt-Org-Id: your-org-uuid
How It Works#
- Build Completes → Jenkins sends webhook to
/api/webhooks/jenkins - Authentication → Webhook verifies API key or org ID
- Project Matching → System tries to match job name/URL to a project
- Queue or Create:
- If project + active release found → Build created directly
- If project found but no release → Queued for release assignment
- If no project match → Queued for project + release assignment
- Assignment → User assigns queued builds via Releases page
Build Queue UI#
The Build Queue appears on the Releases page when there are pending builds:
- Shows build name, source (Jenkins), project, commit/branch
- Assign to Release: Select an active release for the project
- Select Project: Navigate to projects if project not auto-detected
- Reject: Remove build from queue (no build created)
Payload Format#
Jenkins webhooks should include this JSON payload:
{
"build": {
"number": 123,
"phase": "COMPLETED",
"status": "SUCCESS",
"url": "https://jenkins.example.com/job/MyJob/123/"
},
"project": {
"name": "MyJob",
"url": "https://jenkins.example.com/job/MyJob/"
},
"scm": {
"branch": "main",
"commit": "abc123def456"
}
}
Phase values: STARTED, COMPLETED, FINALIZED
Status values: SUCCESS, FAILURE, UNSTABLE, ABORTED
Troubleshooting#
Builds not appearing
- Check Jenkins console output for HTTP request errors
- Verify API key is valid and not expired
- Ensure the webhook URL is correct
- Check Jenkins system logs for errors
Wrong project assigned
The system matches by:
- Job URL (exact match)
- Job name (partial match)
- Repository URL (if provided in payload)
You can manually assign to the correct project from the queue.
Rate limiting
API keys are limited to 60 requests per minute by default. Contact support to increase limits.
SSL/TLS errors
If your Jenkins instance uses self-signed certificates:
- Use valid SSL certificates in production
- Or configure Jenkins to ignore SSL errors (not recommended)
Security#
- API keys are hashed using SHA-256 before storage
- Only the first 12 characters are stored for identification
- Keys can be revoked at any time
- Store API keys in Jenkins Credentials, never in code
- Use Jenkins credential masking to prevent key exposure in logs
- All webhook communications use HTTPS
Unlinking Jenkins#
To disconnect:
- Go to your Jenkins job configuration
- Remove the HTTP Request post-build action
- Or remove the webhook code from your Jenkinsfile
Note: Previously created builds remain in Lathe Studio. New builds will not be created until reconnected.
Advanced Configuration#
Multi-Branch Pipelines
For multi-branch pipeline jobs:
pipeline { agent any post { always { script { def branchName = env.BRANCH_NAME def shouldNotify = branchName in ['main', 'develop', 'release/*'] if (shouldNotify) { // Send webhook } } } } }
Blue Ocean Support
The integration works with both classic Jenkins and Blue Ocean pipelines.
For additional help, contact support.