Skip to main content

ServiceNow CMDB integration for SCP unified model

Project description

ServiceNow CMDB Integration

Sync SCP unified model JSON to ServiceNow Configuration Management Database (CMDB).

Installation

cd packages/vendor/servicenow
uv sync

Quick Start

# Set credentials
export SERVICENOW_INSTANCE="https://dev12345.service-now.com"
export SERVICENOW_USERNAME="admin"
export SERVICENOW_PASSWORD="password"

# Sync (uses sensible defaults)
scp-servicenow cmdb sync graph.json

That's it! The integration works out-of-the-box with sensible defaults. No configuration file needed.


Commands

sync - Sync SCP graph to ServiceNow

scp-servicenow cmdb sync graph.json [OPTIONS]

Options:

  • --instance, -i - ServiceNow instance URL (overrides env var)
  • --ci-class, -c - CI class to use (default: cmdb_ci_service_discovered)
  • --dry-run, -d - Validate without making changes
  • --config - Path to custom cmdb.yaml config file

Examples:

# Basic sync
scp-servicenow cmdb sync graph.json

# Dry-run
scp-servicenow cmdb sync graph.json --dry-run

# Custom config
scp-servicenow cmdb sync graph.json --config my-cmdb.yaml

validate - Validate SCP graph mapping

scp-servicenow cmdb validate graph.json

Checks for mapping issues before syncing.

init - Generate configuration template

scp-servicenow cmdb init [OPTIONS]

Generates a cmdb.yaml configuration file with defaults that you can customize.

Options:

  • --output, -o - Output path (default: cmdb.yaml)
  • --force, -f - Overwrite existing file

Examples:

# Generate config template
scp-servicenow cmdb init

# Custom path
scp-servicenow cmdb init --output config/prod-cmdb.yaml

Default Field Mappings

The integration works without configuration using these defaults:

SCP Field ServiceNow Field Notes
node.id (URN) correlation_id Unique identifier for idempotent upserts
node.name name CI display name
node.tier business_criticality 1→Critical, 2→High, 3→Medium, 4→Low
node.team comments Stored in metadata section
node.domain comments Stored in metadata section
node.contacts[] owned_by + comments Email→User lookup, others in metadata
node.escalation[] comments Formatted escalation chain
edge.DEPENDS_ON cmdb_rel_ci Relationship: "Depends on::Used by"

Comments Field Format

By default, team, domain, contacts, and escalation are stored in the comments field:

SCP Metadata:
Team: checkout-team
Domain: payments

Contacts:
  - pagerduty: acmepay-checkout-critical
  - slack: #team-checkout

Escalation Chain:
checkout-team → payments-platform

Configuration (Optional)

When to Use Configuration

Configuration is OPTIONAL. Use cmdb.yaml if you need to:

  • Map SCP fields to custom ServiceNow fields (e.g., u_business_domain)
  • Customize the comments template format
  • Change tier-to-criticality mappings
  • Disable email-to-user resolution

Generate Configuration Template

scp-servicenow cmdb init

This creates cmdb.yaml with all defaults. Edit to customize for your instance.

Example: Using Custom Fields

If your ServiceNow instance has custom fields:

# cmdb.yaml
field_mappings:
  name: name
  business_criticality: tier
  u_business_domain: domain # Custom field (must exist in ServiceNow)
  u_support_team: team # Custom field (must exist in ServiceNow)
  comments:
    - contacts
    - escalation

Note: Custom fields (u_*) must be created in ServiceNow first. See Creating Custom Fields.

Configuration Options

# Field mappings
field_mappings:
  name: name # Standard field
  business_criticality: tier # Via tier_mappings
  comments: [team, domain, ...] # List of fields to store in comments

# Tier to criticality mapping
tier_mappings:
  1: "1 - Critical"
  2: "2 - High"
  # ...

# Contact resolution
contact_resolution:
  resolve_email_to_owned_by: true # Try to map email→owned_by
  email_not_found: "warn" # warn, ignore, or error

# CI class
ci_class: "cmdb_ci_service_discovered"

# Comments template (Python format string)
comments_template: |
  SCP Metadata:
  Team: {team}
  Domain: {domain}
  ...

Authentication

Set environment variables for ServiceNow credentials:

Basic Auth (Recommended for Development)

export SERVICENOW_INSTANCE="https://dev12345.service-now.com"
export SERVICENOW_USERNAME="admin"
export SERVICENOW_PASSWORD="password"

OAuth Bearer Token

export SERVICENOW_INSTANCE="https://dev12345.service-now.com"
export SERVICENOW_TOKEN="your-bearer-token"

OAuth Client Credentials

export SERVICENOW_INSTANCE="https://dev12345.service-now.com"
export SERVICENOW_CLIENT_ID="your-client-id"
export SERVICENOW_CLIENT_SECRET="your-client-secret"

Creating Custom Fields

To use custom fields like u_business_domain or u_support_team:

  1. Navigate to System Definition > Tables in ServiceNow
  2. Find table: cmdb_ci_service_discovered
  3. Add new fields:
    • Column: u_business_domain, Type: String, Length: 100
    • Column: u_support_team, Type: String, Length: 100
  4. Update your cmdb.yaml to use these fields
  5. Run sync

Complete Example

# 1. Generate SCP JSON
cd packages/constructor
uv run scp-cli scan /path/to/repos --export json -o /tmp/graph.json

# 2. (Optional) Generate config template
cd ../vendor/servicenow
uv run scp-servicenow cmdb init

# 3. (Optional) Edit config to use custom fields
# vim cmdb.yaml

# 4. Set credentials
export SERVICENOW_INSTANCE="https://dev12345.service-now.com"
export SERVICENOW_USERNAME="admin"
export SERVICENOW_PASSWORD="password"

# 5. Dry-run to validate
uv run scp-servicenow cmdb sync /tmp/graph.json --dry-run

# 6. Sync to ServiceNow
uv run scp-servicenow cmdb sync /tmp/graph.json

Troubleshooting

No configuration file found (Warning)

This is OK! The integration works with defaults. Only create cmdb.yaml if you need custom mappings.

Custom field not populated

Verify the field exists in ServiceNow:

  1. Check sys_dictionary table for your field
  2. Ensure field name matches exactly (case-sensitive)
  3. Confirm you're using the correct CI table

Email contact not resolving to owned_by

Check that:

  1. Email address matches a ServiceNow user exactly
  2. User exists in sys_user table
  3. contact_resolution.resolve_email_to_owned_by is true (default)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scp_servicenow-0.1.2.tar.gz (47.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scp_servicenow-0.1.2-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file scp_servicenow-0.1.2.tar.gz.

File metadata

  • Download URL: scp_servicenow-0.1.2.tar.gz
  • Upload date:
  • Size: 47.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for scp_servicenow-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4ce0265230fa7c4b68bd4460602d988815804913b9d7a844ef7b580fda962fac
MD5 6bb2553261b8e6e8ea11e54f03e50f01
BLAKE2b-256 e1ea6111ac1aa8a38dd6f5ce4c845c3badb1c15a7ed164a66a7a9decf8df924a

See more details on using hashes here.

Provenance

The following attestation bundles were made for scp_servicenow-0.1.2.tar.gz:

Publisher: ci.yml on krackenservices/scp-integrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scp_servicenow-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: scp_servicenow-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for scp_servicenow-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 42e5d365773f3c786c1ddeed96a7b3fbd0374d2961c939931bc98d91df4c5ceb
MD5 7fdef43e392bcbd30e91bf1b9d9a2310
BLAKE2b-256 375185ba177182fad3061fc21cc4b73284953db40cdf003ad5dca26544e50b24

See more details on using hashes here.

Provenance

The following attestation bundles were made for scp_servicenow-0.1.2-py3-none-any.whl:

Publisher: ci.yml on krackenservices/scp-integrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page