ServiceNow Jenkins integration creates a seamless DevOps workflow by connecting change management processes with continuous integration and deployment pipelines. This integration enables development teams and release managers to automate build triggers from ServiceNow change records, track deployment artifacts in the CMDB, and maintain compliance through automated change status updates. The integration supports bidirectional communication, allowing ServiceNow to trigger Jenkins builds through REST API calls while Jenkins updates change record statuses and CMDB configuration items upon build completion. The primary automation pattern uses ServiceNow business rules and scheduled jobs to initiate builds, with Jenkins webhook callbacks updating records in the Change Management and Configuration Management applications.
Prerequisites
- •ServiceNow Tokyo or later with Integration Hub Professional license
- •Jenkins server with REST API enabled and administrator access
- •Jenkins Build Authorization Token Root Plugin installed
- •ServiceNow MID Server if Jenkins is hosted on-premises behind firewall
- •jenkins_admin or equivalent role with build trigger permissions in Jenkins
- •itil or admin role in ServiceNow for CMDB and Change Management access
- •Valid SSL certificate on Jenkins server for HTTPS communication
Architecture Overview
The integration utilizes ServiceNow's REST Message framework combined with the DevOps Integration Hub spoke to communicate with Jenkins REST API endpoints. Authentication is established using API tokens stored in ServiceNow Connection & Credential Alias records, with credentials encrypted in the sys_auth table. Data flows bidirectionally with ServiceNow initiating builds via outbound REST calls to Jenkins /job/{job-name}/build endpoints, while Jenkins returns build status through webhooks or polling mechanisms that update Change Request and CMDB records. A MID Server is required when Jenkins resides on-premises or in private networks to proxy REST communications through the corporate firewall. The integration must respect Jenkins' default rate limit of 100 requests per minute per user, with recommended implementation using queued processing for bulk operations.
Sourdough: ServiceNow Monitoring and Analytics
A Chrome extension for ServiceNow Admins and Developers with essential tools, analytics, graphs and monitoring features.
Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.
Implementation Steps
Generate Jenkins API token and configure user permissions
Log into Jenkins as an administrator and navigate to Manage Jenkins > Manage Users. Select your integration user account and click Configure, then scroll to the API Token section and click Add new Token. Provide a descriptive name like 'ServiceNow Integration Token' and click Generate to create the token. Copy the generated token immediately as it cannot be retrieved later. Ensure the user account has Job Build, Job Read, and Job Workspace permissions on all jobs that will be triggered by ServiceNow.
Create Connection and Credential Alias records in ServiceNow
Navigate to Connections & Credentials > Connections and create a new HTTP(s) Connection record with Name 'Jenkins Production Server' and Connection URL pointing to your Jenkins base URL (e.g., https://jenkins.company.com). Create a Credential Alias by going to Connections & Credentials > Credentials, selecting Basic Auth credentials type, and entering your Jenkins username and the API token as the password. Set the Name field to 'Jenkins API Credentials' and link it to your Connection record. Test the connection using the Test Connection button to verify authentication is working properly.
Install and configure the DevOps Integration Hub spoke
Navigate to System Applications > All Available Applications > All and search for 'DevOps' to locate the Integration Hub DevOps spoke. Click Install and wait for the installation to complete, then go to Process Automation > Flow Designer to access the DevOps actions. Configure the Jenkins connection by creating a new flow and adding the 'Jenkins - Trigger Build' action, then map it to your Connection Alias record created in the previous step. The spoke provides pre-built actions for triggering builds, retrieving build status, and downloading build artifacts without custom scripting.
Create REST Message record for Jenkins build triggers
Navigate to System Web Services > Outbound > REST Message and create a new record named 'Jenkins Build Integration'. Set the Endpoint to your Jenkins server base URL and create an HTTP Method with Name 'Trigger Build' using POST method. Configure the Endpoint as '/job/${job_name}/buildWithParameters' and add HTTP Headers including 'Authorization' with value 'Basic ${credentials}' where credentials is base64 encoded username:token. Set up variable substitutions for job_name and any build parameters your Jenkins jobs require. Use the Test functionality to verify successful communication and proper job triggering.
var rm = new RESTMessage('Jenkins Build Integration', 'Trigger Build');
rm.setStringParameterNoEscape('job_name', 'my-deployment-job');
rm.setRequestHeader('Authorization', 'Basic ' + gs.base64Encode(username + ':' + api_token));
rm.setRequestBody(JSON.stringify({parameter: [{name: 'CHANGE_NUMBER', value: current.number}]}));
var response = rm.execute();
gs.info('Build triggered with status: ' + response.getStatusCode());Configure Jenkins webhooks for build status updates
Install the Generic Webhook Trigger Plugin in Jenkins and configure it in your deployment jobs under Build Triggers section. Set the webhook URL to your ServiceNow instance using the format https://instance.service-now.com/api/now/table/x_jenkins_builds with authentication headers. Create a Scripted REST API in ServiceNow by navigating to System Web Services > Scripted Web Services > Scripted REST APIs to receive webhook payloads. Configure the API to parse Jenkins build results and update corresponding Change Request records with build status, log URLs, and artifact information. Include error handling for malformed payloads and duplicate build notifications.
(function process(request, response) {
var payload = JSON.parse(request.body.data);
var changeGR = new GlideRecord('change_request');
if (changeGR.get('number', payload.CHANGE_NUMBER)) {
changeGR.u_build_status = payload.build_result;
changeGR.u_build_url = payload.build_url;
changeGR.u_build_number = payload.build_number;
if (payload.build_result === 'SUCCESS') {
changeGR.state = '3'; // Authorize
} else {
changeGR.state = '-4'; // Failed
}
changeGR.update();
response.setStatus(200);
}
})(request, response);Create business rules for automatic build triggering
Navigate to System Definition > Business Rules and create a new rule named 'Trigger Jenkins Build on Change Approval'. Set the Table to Change Request [change_request] and configure conditions to trigger when State changes to Scheduled and Category equals Software Deployment. In the Script field, implement logic to call your REST Message record, passing the change number and relevant deployment parameters. Add error handling to update the change record with failure information if the Jenkins API call fails. Include logging statements to track build trigger events in the ServiceNow system logs for troubleshooting purposes.
(function executeRule(current, previous) {
if (current.state == '2' && current.category == 'software') {
try {
var rm = new RESTMessage('Jenkins Build Integration', 'Trigger Build');
rm.setStringParameterNoEscape('job_name', current.u_deployment_job.toString());
rm.setRequestBody(JSON.stringify({
CHANGE_NUMBER: current.number.toString(),
ENVIRONMENT: current.u_target_environment.toString(),
DEPLOYMENT_WINDOW: current.start_date.toString()
}));
var response = rm.execute();
if (response.getStatusCode() == 201) {
current.work_notes = 'Jenkins build triggered successfully';
current.u_build_status = 'TRIGGERED';
}
} catch (ex) {
gs.error('Failed to trigger Jenkins build: ' + ex.getMessage());
current.work_notes = 'Failed to trigger deployment build: ' + ex.getMessage();
}
}
})(current, previous);Implement CMDB artifact tracking for deployed builds
Navigate to Configuration > Application Menus and create a custom table 'Deployment Artifacts' [u_deployment_artifacts] with fields for build number, artifact name, version, deployment timestamp, and related CI. Create a scheduled script execution job that queries Jenkins for successful build artifacts and creates corresponding CMDB records. Configure the script to establish relationships between deployed artifacts and their target configuration items using CMDB relationship records. Set up the job to run every 15 minutes to maintain near real-time synchronization between Jenkins build artifacts and CMDB data. Include data validation to prevent duplicate artifact records and maintain referential integrity.
var rm = new RESTMessage('Jenkins Build Integration', 'Get Build Artifacts');
rm.setStringParameterNoEscape('job_name', job_name);
rm.setStringParameterNoEscape('build_number', build_number);
var response = rm.execute();
var artifacts = JSON.parse(response.getBody()).artifacts;
for (var i = 0; i < artifacts.length; i++) {
var artifactGR = new GlideRecord('u_deployment_artifacts');
artifactGR.initialize();
artifactGR.u_artifact_name = artifacts[i].fileName;
artifactGR.u_build_number = build_number;
artifactGR.u_deployment_date = new GlideDateTime();
artifactGR.u_related_ci = target_ci_sys_id;
artifactGR.insert();
}Test end-to-end integration and configure monitoring
Create a test Change Request record with appropriate category and deployment job configuration, then advance it to Scheduled state to trigger the Jenkins build automatically. Monitor the ServiceNow system logs and Jenkins build console to verify successful communication and build execution. Set up automated monitoring by creating a scheduled job that checks for failed build triggers or stuck change records, sending notifications to the DevOps team when issues are detected. Configure ServiceNow Event Management to create incidents when Jenkins webhook callbacks fail or when builds remain in pending status for extended periods. Document the integration workflow and create runbooks for common troubleshooting scenarios to support ongoing operations.
var failedBuilds = new GlideRecord('change_request');
failedBuilds.addQuery('u_build_status', 'TRIGGERED');
failedBuilds.addQuery('sys_updated_on', '<', gs.minutesAgoStart(30));
failedBuilds.query();
while (failedBuilds.next()) {
var event = new GlideEvent();
event.setEventName('jenkins.build.timeout');
event.setParameter('change_number', failedBuilds.number.toString());
event.setParameter('build_job', failedBuilds.u_deployment_job.toString());
event.fire();
gs.warn('Build timeout detected for change: ' + failedBuilds.number);
}Common Use Cases
Automated deployment builds triggered by change approval
When a Change Request for software deployment reaches Scheduled status, ServiceNow automatically triggers the corresponding Jenkins deployment job with change-specific parameters. The integration passes change number, target environment, and deployment window details to Jenkins as build parameters. Jenkins executes the deployment pipeline and returns success or failure status to update the change record state automatically. This eliminates manual coordination between change management and deployment teams while maintaining audit trails for compliance requirements.
CMDB synchronization with deployed application versions
After successful Jenkins builds, the integration automatically creates or updates Configuration Items in the CMDB with new application version information and deployment artifacts. Build metadata including version numbers, deployment timestamps, and artifact checksums are stored as CI attributes for accurate configuration tracking. The system establishes relationships between application CIs and their underlying infrastructure components to maintain complete dependency mapping. This provides real-time visibility into what software versions are running across environments for security scanning and compliance reporting.
Emergency change fast-track deployments
Emergency changes bypass normal approval workflows and immediately trigger priority Jenkins builds with expedited deployment pipelines. The integration automatically sets Jenkins build priority parameters and notifies on-call teams through ServiceNow Event Management when emergency deployments begin. Build results are tracked with enhanced monitoring and automatic escalation if emergency deployments fail or exceed expected duration. This ensures critical fixes reach production quickly while maintaining change documentation and rollback capabilities.
Multi-environment promotion workflows
ServiceNow orchestrates Jenkins builds across multiple environments using sequential change records that represent each promotion stage from development through production. Each environment promotion triggers a specific Jenkins job configured for that target environment, with automatic progression to the next stage upon successful deployment. The integration maintains dependency tracking between environments and prevents production deployments if lower environments show build failures. This creates a controlled promotion pipeline that enforces governance while automating the technical deployment process.
Rollback coordination and artifact management
When change records are moved to a rollback state, the integration automatically triggers Jenkins rollback jobs that deploy previously successful artifact versions. ServiceNow maintains a history of deployed artifacts per environment and identifies the last known good version for automatic rollback execution. Build artifacts and deployment scripts are archived in Jenkins with metadata links to their originating change records for complete traceability. This enables rapid recovery from failed deployments while preserving audit evidence of all deployment activities and their business justifications.
Troubleshooting
Jenkins build triggers fail with '403 Forbidden' authentication errors
Check that the Jenkins API token is correctly encoded in the ServiceNow Credential record and hasn't expired or been revoked in Jenkins. Navigate to System Logs > System Log > All to review the outbound HTTP request details and verify the Authorization header format. Confirm the Jenkins user account has appropriate permissions for the specific job being triggered by testing the same API call manually using curl or Postman. If using CSRF protection in Jenkins, add the Jenkins-Crumb header to your REST Message configuration.
Webhook callbacks from Jenkins are not updating ServiceNow records
Verify that your ServiceNow Scripted REST API endpoint is accessible from the Jenkins server by testing the URL directly from the Jenkins host. Check the ServiceNow Application Logs under System Logs > Application Logs for any parsing errors in the webhook payload processing script. Ensure the Jenkins Generic Webhook Trigger Plugin is configured with the correct ServiceNow instance URL and authentication headers. Review Jenkins build console output to confirm webhook calls are being attempted and check for network connectivity issues or firewall restrictions.
CMDB artifact records contain duplicate or missing build information
Examine the scheduled job that synchronizes Jenkins artifacts with CMDB records for proper error handling and duplicate detection logic. Check if the Jenkins API pagination is being handled correctly when retrieving build artifacts, as large builds may return paginated results. Review the GlideRecord queries used to check for existing artifact records and ensure unique field combinations are being validated properly. Implement transaction logging in your synchronization script to track which builds have been processed and identify any gaps in the synchronization process.
Change Request states are not updating after Jenkins build completion
Review the Jenkins webhook payload format to ensure it contains all required fields expected by your ServiceNow webhook processor script. Check that the Change Request lookup logic in your Scripted REST API is correctly matching Jenkins build parameters to ServiceNow change numbers. Verify that the ServiceNow user context for the webhook API has sufficient privileges to update Change Request records and isn't blocked by business rules or ACLs. Enable debug logging in your webhook processor to trace payload parsing and record update operations step by step.
MID Server connectivity issues preventing Jenkins communication
Check the MID Server status and capabilities in ServiceNow under MID Server > Servers to ensure it's active and has the REST capability enabled. Test direct connectivity from the MID Server host to your Jenkins server using telnet or curl commands to verify network access and DNS resolution. Review MID Server logs on the host system for connection timeout or SSL certificate validation errors that might be blocking HTTPS communication. If using self-signed certificates, configure the MID Server Java keystore to trust your Jenkins SSL certificate.
Jenkins job parameters are not being passed correctly from ServiceNow
Verify that your REST Message HTTP Method is configured with the correct parameter names and data types expected by the Jenkins job definition. Check that JSON payload formatting in your ServiceNow script matches the Jenkins API requirements for build parameters, particularly for complex objects or arrays. Use the REST Message test functionality to inspect the exact HTTP request being sent and compare it with Jenkins API documentation. Review Jenkins job configuration to ensure parameter defaults are set appropriately for optional parameters that might not be provided by ServiceNow.
Pro Tips
- →Implement retry logic with exponential backoff in your ServiceNow business rules to handle temporary Jenkins server unavailability, storing failed requests in a custom queue table for later processing. This prevents lost build triggers during maintenance windows or network issues while avoiding overwhelming Jenkins with repeated immediate retry attempts.
- →Use ServiceNow's Flow Designer instead of business rules for complex Jenkins integration workflows, as flows provide better error handling, visual debugging, and can leverage the pre-built DevOps spoke actions. Flows also support parallel processing for multi-environment deployments and conditional logic for different deployment types without complex scripting.
- →Configure Jenkins build parameters to include ServiceNow change request URLs and context information, enabling Jenkins build logs to link back to their originating change records for improved traceability. This creates bidirectional navigation between systems and helps developers understand the business context behind their deployments.
- →Implement circuit breaker patterns in your integration scripts to automatically disable Jenkins build triggering when error rates exceed thresholds, preventing cascading failures during Jenkins outages. Use ServiceNow's sys_properties table to store circuit breaker state and automatically re-enable integration once Jenkins health checks pass.
- →Leverage ServiceNow's Transform Maps feature to standardize Jenkins webhook payloads into consistent ServiceNow record formats, making your integration more resilient to Jenkins plugin updates or different job types. This abstraction layer simplifies maintenance and allows for easier integration testing with mock data.
- →Set up ServiceNow Performance Analytics dashboards to track integration metrics like build trigger success rates, average deployment times, and change-to-deployment lead times. These metrics provide valuable insights for DevOps process improvements and help identify bottlenecks in your CI/CD pipeline.
Known Limitations
- —Jenkins REST API has a default rate limit of 100 requests per minute per user, which can be exceeded during bulk change processing or concurrent deployments, requiring queue-based processing for high-volume scenarios. Large ServiceNow instances may need to implement token rotation across multiple Jenkins users or coordinate request timing to stay within limits.
- —The DevOps Integration Hub spoke requires Professional licensing and may not support all Jenkins plugin-specific features or custom build parameter types, necessitating fallback to custom REST Message implementations for advanced use cases. Integration Hub actions also run on ServiceNow infrastructure rather than MID Servers, which may impact connectivity to on-premises Jenkins instances.
- —CMDB artifact synchronization can create significant data volumes over time, as Jenkins builds generate multiple artifacts per deployment, potentially impacting ServiceNow database performance without proper archival strategies. Historical artifact data retention policies must be balanced against compliance requirements and storage costs.
- —Jenkins webhook callbacks can fail silently if ServiceNow instances are temporarily unavailable during deployments, creating gaps in change record status updates that require manual reconciliation. Network latency and timeout configurations between Jenkins and ServiceNow can also cause inconsistent callback delivery during peak usage periods.
- —Complex Jenkins pipeline jobs with dynamic stage generation or conditional deployment paths may not map cleanly to ServiceNow's linear change management workflow, requiring custom logic to handle pipeline branches and stage-specific status updates. Multi-branch pipeline builds particularly challenge traditional change record associations when feature branches deploy to development environments.
Frequently Asked Questions
Can ServiceNow trigger Jenkins builds that require manual approval steps within the Jenkins pipeline?
Yes, ServiceNow can trigger Jenkins pipelines with manual approval steps, but the integration requires additional configuration to handle pipeline pauses and user input. You'll need to implement polling mechanisms in ServiceNow to check pipeline status periodically and potentially create ServiceNow approval records that correspond to Jenkins pipeline approval steps. Consider using Jenkins' REST API to retrieve pipeline stage information and create ServiceNow workflows that mirror the Jenkins approval process for consistent governance across both platforms.
How do I handle Jenkins builds that deploy to multiple environments sequentially?
Implement a parent-child change request structure where the parent represents the overall deployment initiative and child changes represent each environment-specific deployment stage. Use ServiceNow business rules to automatically create child changes for each environment and trigger corresponding Jenkins jobs in sequence based on the success of previous stages. The Jenkins webhook callbacks should update individual child change records while rolling up overall progress to the parent change, providing both detailed stage-level tracking and high-level deployment status visibility.
What's the best approach for handling Jenkins build artifacts that need to be promoted across environments?
Create a custom ServiceNow table to track build artifacts with fields for artifact version, environment deployment status, and promotion eligibility flags based on testing results. Use Jenkins to publish artifact metadata to ServiceNow after successful builds, then implement ServiceNow workflows that control artifact promotion by triggering downstream Jenkins jobs with specific artifact versions. This approach maintains artifact traceability across environments while ensuring only tested and approved versions reach production through ServiceNow governance processes.
How can I integrate Jenkins pipeline test results with ServiceNow change risk assessment?
Configure Jenkins to publish test results and code quality metrics to ServiceNow through webhook callbacks or REST API calls after pipeline completion. Create calculated fields on change records that automatically adjust change risk scores based on test coverage percentages, security scan results, and performance test outcomes received from Jenkins. This integration enables ServiceNow's change advisory board to make informed approval decisions based on objective technical metrics rather than manual assessments, improving change success rates and reducing production incidents.
Can the integration work with Jenkins multi-branch pipelines and feature branch deployments?
Yes, but it requires additional configuration to handle the dynamic nature of multi-branch pipelines where branch names and deployment targets vary. Implement ServiceNow logic to parse Jenkins webhook payloads for branch information and automatically categorize deployments as development, feature testing, or production based on branch naming conventions. Create separate change request templates for feature branch deployments with streamlined approval processes, while maintaining full governance for master branch deployments to production environments.
How do I troubleshoot ServiceNow to Jenkins connectivity issues through a MID Server?
Start by checking MID Server status in ServiceNow under MID Server > Servers and verify the server shows as Up with REST capabilities enabled. Test direct connectivity from the MID Server host to Jenkins using curl commands with the same URL and authentication headers configured in your ServiceNow integration. Review MID Server logs in the agent/logs directory for SSL handshake failures, DNS resolution issues, or HTTP timeout errors that might indicate network or firewall problems requiring infrastructure team assistance.
What security considerations should I address when implementing this integration?
Store Jenkins API tokens using ServiceNow's encrypted credential storage rather than hardcoding them in scripts, and implement token rotation policies to regularly refresh authentication credentials. Configure Jenkins webhook URLs to use HTTPS with certificate validation and consider implementing webhook signature validation to prevent malicious payload injection. Restrict ServiceNow user accounts used for Jenkins API calls to minimum required permissions and implement audit logging for all integration activities to maintain compliance with security governance requirements and enable forensic analysis of deployment activities.
Test Your Knowledge
Quick 3-question quiz — see how your ServiceNow skills stack up.
A list view on a table with millions of records is slow. Best fix?
Select an answer to continue