Configure Jenkins for Deploy Change Investigator
Send build and deployment webhooks from your pipelines
Configure Jenkins pipelines to send build and deployment data to the Deploy Change Investigator using shell scripts.
Before you begin
Deploy Change Investigator setup: Create build and deploy webhook integrations in AI SRE. Go to Deploy Change Investigator to set up the integrations.
Jenkins pipeline access: Permission to edit the Jenkinsfile or add build steps.
Webhook URLs: Copy the build and deploy webhook URLs from your AI SRE integrations.
Git plugin: Ensure the Jenkins Git plugin is installed for commit SHA access.
Configure build webhooks
Add a shell script step to your Jenkins build pipeline that runs after the artifact is published.
Declarative pipeline
Add this step to your post section or as the last step in your build stage:
pipeline {
agent any
environment {
BUILD_WEBHOOK_URL = credentials('aisre-build-webhook-url')
ARTIFACT_REGISTRY = 'docker.example.com'
SERVICE_NAME = 'myapp'
}
stages {
stage('Build') {
steps {
// Your build steps here
sh 'docker build -t ${ARTIFACT_REGISTRY}/${SERVICE_NAME}:${BUILD_NUMBER} .'
sh 'docker push ${ARTIFACT_REGISTRY}/${SERVICE_NAME}:${BUILD_NUMBER}'
}
}
}
post {
success {
script {
sh '''#!/bin/bash
json_payload="{\
\\"artifact\\": {\\"name\\": \\"${ARTIFACT_REGISTRY}/${SERVICE_NAME}\\", \\"version\\": \\"${BUILD_NUMBER}\\"},\
\\"source\\": {\
\\"commitSha\\": \\"${GIT_COMMIT}\\",\
\\"kind\\": \\"branch\\",\
\\"value\\": \\"${GIT_BRANCH}\\",\
\\"repository_url\\": \\"${GIT_URL}\\"},\
\\"service\\": {\\"name\\": \\"${SERVICE_NAME}\\", \\"version\\": \\"${BUILD_NUMBER}\\"},\
\\"buildId\\": \\"${BUILD_ID}\\"}"
curl "${BUILD_WEBHOOK_URL}" \\
-s \\
-H "Content-Type: application/json" \\
-d "${json_payload}"
'''
}
}
}
}Scripted pipeline
Environment variables reference
Jenkins provides these environment variables automatically:
GIT_COMMIT: Full SHA of the commit being built.
GIT_BRANCH: Branch name (for example,
origin/main).GIT_URL: Git repository URL.
BUILD_ID: Unique Jenkins build ID.
BUILD_NUMBER: Sequential build number.
Custom variables to set:
BUILD_WEBHOOK_URL: Store as a Jenkins credential (Secret text).
ARTIFACT_REGISTRY: Your Docker or artifact registry URL.
SERVICE_NAME: Service identifier.
Configure deploy webhooks
Add a shell script step to your Jenkins deployment pipeline that runs after the deployment completes.
Declarative pipeline
Multi-service deployments
For deployments that update multiple services:
Store webhook URLs as credentials
Store webhook URLs securely in Jenkins:
Navigate to Manage Jenkins, then select Credentials
Select the appropriate domain (usually
(global))Click Add Credentials
Configure the following:
Kind: Secret text
Secret: Paste your build or deploy webhook URL
ID:
aisre-build-webhook-urloraisre-deploy-webhook-urlDescription: "AI SRE Build Webhook URL" or "AI SRE Deploy Webhook URL"
Click OK
Reference credentials in Jenkinsfile:
Critical mapping requirements
The Deploy Change Investigator requires exact matches between build and deploy data:
service.name
services[].service
✅ Yes
artifact.version or service.version
services[].version
✅ Yes
COMMON MISTAKES
Version mismatch: Build sends
1.2.3, deploy sendsv1.2.3, so there is no match.Service name mismatch: Build sends
myapp, deploy sendsmy-app, so there is no match.Using different identifiers: Ensure the BUILD_NUMBER or version tag is consistent across both webhooks.
Testing webhooks
Test build webhook
Trigger a build and confirm the webhook reaches AI SRE:
Trigger a Jenkins build that includes the webhook script
Check the Jenkins console output for curl command execution
Navigate to AI SRE, then select Integrations
Click the More icon on the BUILD integration
Select Debug to view received webhook events
Test deploy webhook
Trigger a deployment and confirm the webhook reaches AI SRE:
Trigger a deployment pipeline
Verify the curl command runs in the console output
Navigate to AI SRE, select Integrations, then select Debug on the DEPLOY integration
Verify the connection
After sending both build and deploy webhooks:
Navigate to AI SRE, then select Change Management
You should see deployment records linked to builds
Click into a deployment to see the following:
Artifact versions
Commit SHAs
Linked PRs
Troubleshooting
Example complete Jenkins pipeline
The following is a complete example with both build and deploy webhooks:
Next steps
Go to Deploy Change Investigator to complete the setup.
Go to AI Agent RCA to understand how change detection works during incidents.
Go to Configure GitHub Actions to set up webhooks in GitHub Actions workflows.
Last updated
Was this helpful?