Jenkins Integration¶
Connect Jenkins pipelines to SerOps for build and deployment tracking.
Prerequisites¶
- Jenkins Server (v2.0+)
- User with API Token
- Network access from SerOps to Jenkins URL
Setup¶
Jenkins integrations are configured in Integrations.
- In Jenkins: User Profile → Configure → API Token
- Click Add new Token and give it a name (e.g., "SerOps Integration")
- Copy the generated token
- In SerOps: Integrations
- Click + Add Integration and select Jenkins
- Enter:
- Name: Identifier (e.g., "Production Jenkins")
- Jenkins URL:
https://jenkins.example.com - Username: Your Jenkins username
- API Token: The token generated above
- Click Test Connection to verify
- Click Save
Once configured, you can link Jenkins to services via the Add Service Wizard (Step 3: CI/CD).
Linking to Services¶
- Create or edit a service in any project
- In the CI/CD step of the wizard, select Jenkins
- Choose your Jenkins integration from the dropdown
- Enter the Pipeline Job Path:
folder/job-name - For folders:
my-folder/my-job - For multibranch:
my-folder/my-job/branch-name
Features¶
| Feature | Description |
|---|---|
| Build Tracking | Sync build status (Success/Failure/Unstable) |
| Log Ingestion | Fetch console logs for failure analysis |
| Environment Detection | Parse branch names to detect environment |
Console Log Capture¶
For failed builds, SerOps fetches the console output: - Up to 1 MB of inline log stored - Error lines extracted for AI analysis - Full log available in batch details
Webhook Configuration (Optional)¶
For real-time updates, configure Jenkins to notify SerOps:
Generic Webhook Trigger Plugin¶
- Install Generic Webhook Trigger Plugin in Jenkins
- In SerOps, find the CI/CD binding for your service and copy the Webhook URL and Token
- URL format:
https://your-serops.com/api/webhooks/jenkins/{binding_id}/ - Token is auto-generated on binding creation
- Alternatively, call
POST /api/projects/cicd-bindings/{id}/setup-webhook/to get the URL - In your pipeline configuration, add a post-build action:
- URL: The binding-specific URL from step 2
- Content-Type:
application/json - Token: The auto-generated token from step 2
Jenkinsfile Example¶
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'make build'
}
}
}
post {
always {
httpRequest(
url: "https://your-serops.com/api/webhooks/jenkins/${SEROPS_BINDING_ID}/",
httpMode: 'POST',
contentType: 'APPLICATION_JSON',
customHeaders: [[name: 'X-Jenkins-Token', value: "${SEROPS_WEBHOOK_TOKEN}"]],
requestBody: """{
"job_name": "${env.JOB_NAME}",
"build_number": "${env.BUILD_NUMBER}",
"status": "${currentBuild.result}",
"branch": "${env.GIT_BRANCH}"
}"""
)
}
}
}
Note: Set
SEROPS_BINDING_IDandSEROPS_WEBHOOK_TOKENas Jenkins credentials or environment variables from your CI/CD binding in SerOps.
Environment Mapping¶
SerOps detects environments from Jenkins job/branch names:
| Pattern | Environment |
|---|---|
*-prod*, *-production* |
production |
*-staging*, *-stage* |
staging |
*-dev*, *-develop* |
development |
main, master |
production |
Troubleshooting¶
| Issue | Solution |
|---|---|
| "403 Forbidden" | Enable CSRF crumb in Jenkins or disable CSRF for API |
| "Connection Refused" | Check firewall allows traffic from SerOps |
| "401 Unauthorized" | Verify username and token are correct |
| "Job Not Found" | Use full path for folders (e.g., folder/job) |
| "No builds syncing" | Check job has recent builds and webhook is configured |
CSRF Configuration¶
If using Jenkins 2.x with CSRF protection:
- Go to Manage Jenkins → Configure Global Security
- Under CSRF Protection, enable "Enable proxy compatibility"
Or add SerOps IP to the CSRF whitelist.