CI/CD Integration Overview
Overview of ServiceNow integration patterns and concepts for CI/CD pipelines
Introduction
This guide provides platform-agnostic concepts and patterns for integrating ServiceNow with any CI/CD platform. Use this as a foundation before implementing platform-specific integrations.
Integration Architecture
High-Level Flow
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CI/CD Pipeline β
β β
β ββββββββ ββββββββ ββββββββ ββββββββ ββββββββββββ β
β βBuild βββββ Test βββββ Scan βββββStage βββββProductionβ β
β ββββββββ ββββββββ ββββββββ βββββ¬βββ ββββββ¬ββββββ β
β β β β
ββββββββββββββββββββββββββββββββββββββββββΌββββββββββββΌββββββββββ
β β
ββββββββββββββββββββββ β
β β
βΌ βΌ
ββββββββββββββββββββββββ ββββββββββββββββββββββββ
β Create Change β β Update Change β
β Request β β (Deployed) β
β β β β
β POST /change_request β β PATCH /change_requestβ
ββββββββββββ¬ββββββββββββ ββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Wait for Approval β
β β
β GET /change_request β
β (Poll or Webhook) β
ββββββββββββ¬ββββββββββββ
β
βΌ
Approved? ββYesβββ Continue Pipeline
β
No
β
βΌ
Block/Fail PipelineIntegration Methods
Method 1: Direct REST API Integration
Description: Pipeline makes direct HTTP calls to ServiceNow REST API
When to Use:
Full control over integration logic
Simple change management workflows
No ServiceNow Integration Hub available
Custom retry and error handling needed
Pros:
β Complete control
β No ServiceNow middleware required
β Works with any CI/CD platform
β Easy to debug and test
Cons:
β Pipeline must handle all logic
β Need to implement retry mechanisms
β Authentication management in pipeline
β More code to maintain
Example Flow:
Method 2: ServiceNow Integration Hub
Description: ServiceNow Integration Hub orchestrates the integration with pre-built spokes
When to Use:
Complex workflows with multiple systems
Enterprise ServiceNow deployment
Need robust error handling and retry
Reusable integration patterns
Pros:
β Pre-built change management spokes
β Built-in error handling and retry
β Visual workflow designer (Flow Designer)
β Reusable across multiple pipelines
β ServiceNow-managed updates
Cons:
β Requires Integration Hub license
β More initial setup complexity
β Limited customization vs. direct API
β Debugging can be challenging
Example Flow:
Method 3: Event-Driven (Webhooks)
Description: CI/CD events trigger ServiceNow webhooks, which execute Flow Designer workflows
When to Use:
Event-driven architecture preferred
Asynchronous processing acceptable
Need to trigger multiple ServiceNow workflows
Loose coupling between systems
Pros:
β Decoupled systems
β Scalable (async processing)
β No polling required
β Supports fan-out to multiple workflows
Cons:
β More complex setup
β Harder to debug
β Network firewall considerations
β Webhook endpoint security critical
Example Flow:
Method 4: Platform-Specific Plugins
Description: Use official ServiceNow plugins/extensions for your CI/CD platform
When to Use:
Platform has official ServiceNow support
Want simplest setup
No custom workflow requirements
Standard change management patterns
Available Platforms:
Azure DevOps: Official ServiceNow extension
Jenkins: ServiceNow plugin
GitHub Actions: Community actions
GitLab: REST API integration (no official plugin)
Pros:
β Easiest setup
β Platform-native configuration
β Maintained by ServiceNow or community
β Built-in best practices
Cons:
β Limited to available platforms
β Less customization
β Plugin update dependencies
β May not fit complex workflows
Core Integration Patterns
Pattern 1: Change Request Lifecycle
Complete change management flow:
Pattern 2: Emergency Change
Expedited process for critical fixes:
Pattern 3: Standard Pre-Approved Change
Fast path for low-risk, repeatable changes:
Pattern 4: Change with Attachments
Include test results and security scan reports:
Pattern 5: Rollback Change
Document rollback as a separate change:
ServiceNow REST API Essentials
Authentication
Basic Authentication (not recommended for production):
OAuth 2.0 (recommended):
Create Change Request
Response:
Get Change Status
Update Change Request
Attach File to Change
Change Request States
Understanding ServiceNow change states:
New
-5
Change created
Wait for approval
Assess
-4
Under assessment
Continue waiting
Authorize
-3
Awaiting authorization
Continue waiting
Scheduled
-2
Approved and scheduled
Can proceed
Implement
-1
Implementation in progress
Deployment happening
Review
0
Post-implementation review
Deployment complete
Closed
3
Change closed
Final state
Canceled
4
Change canceled
Abort deployment
Pipeline Logic:
Error Handling
Retry Strategy
Implement exponential backoff:
Common Error Scenarios
401 Unauthorized
Invalid credentials
Check token/credentials, refresh if expired
403 Forbidden
Insufficient permissions
Verify ServiceNow user has change_request role
404 Not Found
Invalid endpoint/sys_id
Verify URL and change request exists
429 Too Many Requests
Rate limiting
Implement backoff, reduce request frequency
500 Internal Server Error
ServiceNow issue
Retry with exponential backoff
Approval Polling Pattern
Best practice for waiting on approvals:
Security Best Practices
Credential Management
Do:
β Store ServiceNow credentials in secrets management (Vault, CI/CD secrets)
β Use OAuth 2.0 with client credentials flow
β Rotate credentials regularly
β Use least-privilege ServiceNow roles
β Audit ServiceNow API access logs
Don't:
β Hardcode credentials in pipeline code
β Use admin accounts for API access
β Share credentials across teams
β Log credentials in pipeline output
Network Security
Use HTTPS for all ServiceNow API calls
Whitelist CI/CD IPs in ServiceNow if possible
Implement mutual TLS for enterprise deployments
Use ServiceNow IP allowlists
Performance Optimization
Reduce API Calls
Instead of:
Do:
Caching
Cache ServiceNow metadata (assignment groups, CMDB CIs) that doesn't change frequently:
Testing ServiceNow Integration
Development Environment
ServiceNow Developer Instance: Free instance for testing
Mock ServiceNow API: Use tools like WireMock for local testing
Test Change Requests: Create and close changes in non-production
Integration Tests
Monitoring and Observability
Metrics to Track
Change Creation Time: Time to create change via API
Approval Wait Time: Duration waiting for approvals
API Error Rate: Percentage of failed ServiceNow API calls
Change Success Rate: Percentage of changes closed successfully
Pipeline Duration Impact: Extra time added by ServiceNow integration
Alerts
Set up alerts for:
ServiceNow API failures (>5% error rate)
Approval timeouts (>1 hour wait)
Rejected changes (immediate notification)
Change creation failures (blocks deployment)
Logging
Log all ServiceNow interactions:
Next Steps
Now that you understand the core concepts, proceed to platform-specific integration guides:
Additional Resources
Last updated