OBLYTECH Logo
OBLYTECH Logo
ServiceNow and Jenkins Integration Guide
Home / Guides, Services and Solutions / Integrations / ServiceNow and Jenkins Integration Guide

ServiceNow and Jenkins Integration Guide

Integrating Jenkins with ServiceNow links deployments to change records. Jenkins can send build and deployment results into ServiceNow, ServiceNow can trigger a Jenkins deployment after approval, or both can run as a loop. The guide covers data ownership, authentication, monitoring and failure handling.

Why Integrate Jenkins with ServiceNow?

Organizations use Jenkins for continuous integration and continuous deployment. ServiceNow manages change requests and infrastructure configuration. Integrating the two creates a feedback loop: when Jenkins completes a build or deployment, ServiceNow records it; when ServiceNow approves a change, Jenkins can trigger a deployment automatically. This eliminates manual updates and ensures Service Now reflects actual infrastructure state.

Without integration, your team must update ServiceNow manually after Jenkins deploys code, creating a lag between reality and the audit trail. Audit trails fall out of sync, change records lack evidence of execution, and troubleshooting becomes harder because no one knows what actually deployed when.

Common Integration Patterns

Most Jenkins-ServiceNow integrations follow one of three patterns. Inbound integration pulls data from Jenkins into ServiceNow: Jenkins publishes build status, test results, and deployment logs to ServiceNow via REST API, creating or updating change records, incident records, or custom tables. This is the most common pattern because it keeps ServiceNow as the audit record.

Outbound integration pushes change approvals from ServiceNow to Jenkins. When a ServiceNow change is approved, a webhook or REST API call triggers a Jenkins job to deploy code to production. This automates deployment scheduling and ensures deployment only happens when a change ticket is approved.

Bidirectional integration combines both: ServiceNow triggers Jenkins deployments, and Jenkins sends results back to ServiceNow. This creates a complete loop where the entire deployment lifecycle is tracked in ServiceNow and Jenkins executes the work automatically.

Data Ownership and Mapping

Define who owns what data. ServiceNow is typically the system of record for change approvals and compliance audit trails. Jenkins is the system of record for build artifacts and deployment artifacts. Map Jenkins build_id, job_name, and deployment_status to ServiceNow fields. Decide which table (change_request, deployment_record, or custom table) will store Jenkins data. Create a linking field so you can trace back from ServiceNow to Jenkins logs when troubleshooting.

Jenkins typically lacks approval workflows and audit trails; ServiceNow provides those. Store the Jenkins build number, repository branch, and artifact version in ServiceNow so teams can correlate failed deployments to code changes. This is critical for root-cause analysis after an outage.

Authentication Approaches

For Jenkins calling ServiceNow, use either API key authentication or OAuth 2.0 depending on your release and licensing. Create a service account in ServiceNow with permissions to create and update change records only. In Jenkins, store the API key or OAuth token in a credentials plugin (HashiCorp Vault, Jenkins Credentials Store), never hardcoded in pipeline scripts. Rotate credentials on the schedule your security policy sets.

For ServiceNow calling Jenkins, configure a webhook in Jenkins to accept POST requests from ServiceNow. In ServiceNow, define the Jenkins API endpoint and authentication method in the integration properties. Test the connection before deploying to production.

Monitoring Integration Health

Set up alerts for failed API calls. In ServiceNow, create a business rule that triggers if a Jenkins API call times out or returns an error. Log all integration traffic to a custom table for troubleshooting. In Jenkins, monitor webhook delivery and configure retry logic for failed ServiceNow API calls. If ServiceNow is down briefly, Jenkins should queue the deployment status update and retry when ServiceNow recovers.

Handling Failures

Design for failure. If the Jenkins-ServiceNow connection drops mid-deployment, what happens? If Jenkins successfully deploys but fails to update ServiceNow, your audit trail is incomplete. Consider these scenarios: Jenkins deployment succeeds but API call to ServiceNow fails (retry logic in Jenkins solves this). ServiceNow approves a change but Jenkins job is disabled or removed (add pre-deployment validation in Jenkins to check job exists). ServiceNow and Jenkins have conflicting data about deployment status (define resolution rules: trust Jenkins, trust ServiceNow, or escalate to a human).

Integration Design Checklist

Define data mapping: which Jenkins fields flow to which ServiceNow tables. Set authentication: service account credentials, rotation schedule, least-privilege permissions. Plan error handling: what triggers a retry, what escalates to human review. Configure monitoring: log all API calls, set up alerts for failures. Test failover: disconnect the connection and verify behavior. Document the integration: keep a runbook showing what flows where and how to troubleshoot common issues. Plan maintenance windows when you can update either system.

Common Pitfalls

Storing API credentials in pipeline code is a security risk; use a secrets manager. Assuming the connection will never fail leads to untracked deployments; design retry logic. Mapping too many Jenkins fields to ServiceNow creates clutter and noise; keep only what you need for auditing and troubleshooting. Not testing the integration under load can hide race conditions; stress-test your API endpoints.

Deciding where Jenkins waits for ServiceNow and where it only reports

Connecting Jenkins to ServiceNow is less about moving data and more about deciding which pipeline stages are allowed to wait. A stage that checks for an approved change before it deploys is a control. A stage that posts the build result afterwards is a record. Both are useful, but they fail in different ways, and mixing them up is how teams end up with pipelines that stall for hours or deployments that are never checked. Before any plugin is configured, mark each stage of the pipeline as gate, record or neither.

Gates belong where a wrong deployment would cause customer harm or break a regulated process. Records belong almost everywhere else. Neither is needed for a stage that only compiles code or runs unit tests in an isolated build agent, although the results are still worth keeping for audit questions later.

Stage-by-stage decision table

Pipeline stage Role in the ServiceNow link What Jenkins sends or checks Failure behavior to choose
Build and unit tests Record only Build number, branch, artifact version Retry the post, never block the build
Integration and security scans Record with evidence attached Scan summary and result counts Keep the build result; flag the change for review
Pre-production deployment Gate Check that a change in the right state is linked to this build Stop and report; do not deploy on an unknown state
Production deployment Gate plus record Approval state at the moment of deploy, then deploy outcome Stop on gate failure; if the record update fails after a successful deploy, queue it and alert

A build-up sequence that avoids a stalled pipeline

  1. Write down the gate and record stages for each pipeline, and get the change manager to confirm that the gates match the approval policy.
  2. Create the service account in ServiceNow with rights limited to the change tables the pipeline touches, and store its credential in the Jenkins credential store.
  3. Add record-only stages first, so that data flows into ServiceNow without any deployment depending on it.
  4. Add the production gate in a test pipeline, then test three cases: an approved change, a change still waiting, and a change that does not match the build.
  5. Decide how the pipeline behaves when ServiceNow itself is slow or unavailable, and write that rule into the runbook before the gate goes live.
  6. Turn on the production gate for one pipeline, watch the first few releases, and only then apply the pattern to others.

Where the audit trail breaks in practice

A common gap is a deployment that succeeds and then fails to report. The pipeline has done the work, but the record still shows the change as approved and not yet implemented, and an auditor who reads the record will see a mismatch. The second gap is a build that is re-run. Without a unique build key in the record, the second run either creates a duplicate change or overwrites the first run’s evidence. Test both on purpose. Reproduce a dropped network call during deploy, and re-run a finished build, and check what the record looks like afterwards. For what a reviewer will expect to find, see change validation evidence, and for keeping history intact once records change, audit trail evidence is the place to look.

Signs the pipeline link is working

  • Every production deployment has a change record in the implemented state, linked to the build number that shipped.
  • A gate that is waiting for approval shows the reason in the pipeline log, not just a spinning stage.
  • Re-running a build updates the existing evidence rather than creating a second record.
  • When ServiceNow is unreachable, the queued record updates clear once the connection returns, and nothing is deployed on an unknown approval state.

Keep the gate narrow

Every stage that becomes a gate adds a human dependency, and the more gates there are, the more often someone is waiting for someone else. Keep the gate on the production path and resist adding it to staging unless the staging environment is shared with customers or regulated data. A narrow gate that people trust will be used. A wide gate that people route around tends to be bypassed, and the bypass will be the thing the auditor asks about.

Should the pipeline stop if the change record is missing?

Yes, for a production gate. A missing record means no approval can be proven, so the deployment should stop with a clear message. For a record-only stage, the pipeline should continue and raise a task to create the missing record.

How should a rollback appear in the change history?

As its own record step, linked to the original change and the build it reverts to. Do not overwrite the original deployment entry, because the sequence of deploy and rollback is the evidence someone will need after an outage.

Is a webhook from ServiceNow better than polling from Jenkins?

For gates, a poll with a short timeout and a clear status is usually easier to diagnose than a webhook that may be missed. Webhooks suit notifications where a missed message is harmless. Choose by what happens if the message is lost.

Who should be allowed to edit the gate logic?

The pipeline owner proposes changes and the change board reviews them. A change to a gate is itself a production change, and it should be recorded that way.

Next step

If the pipelines are already running and the gate design is the open question, a brief session can resolve the stage mapping sooner.

Frequently asked questions

Should Jenkins or ServiceNow be the system of record for deployments?

ServiceNow should be the audit trail for compliance and change tracking. Jenkins should be the system of record for build artifacts and deployment logs. Link them bidirectionally: Jenkins triggers from ServiceNow approvals, and Jenkins sends deployment status back to ServiceNow for the audit trail.

What happens if a Jenkins deployment succeeds but ServiceNow API fails?

Configure retry logic in Jenkins to re-attempt the ServiceNow API call. If retries fail after a timeout, alert the platform team. A failed update to ServiceNow means the deployment is untracked, which breaks compliance audits. Prevention through retry logic is critical.

How do I secure Jenkins API credentials in ServiceNow?

Store Jenkins API keys in ServiceNow's credential store or an external vault like HashiCorp Vault. Never hardcode credentials in workflow scripts. Use a service account with minimal permissions. Rotate credentials on the schedule your security policy sets.

Talk to Oblytech

Planning, running or fixing a ServiceNow programme? Tell us where you are and we will suggest a sensible next step.

Contact us