Chapter 8. ServiceNow custom actions in Red Hat Developer Hub
Integrate ServiceNow with Red Hat Developer Hub to manage ServiceNow records by using Scaffolder actions and view ServiceNow data on entity pages.
In Red Hat Developer Hub, you can use ServiceNow custom actions to fetch and register resources within the catalog.
The custom actions in Developer Hub help you automate the management of records. By using the custom actions, you can:
- Create, update, or delete a record
- Retrieve information about a single record or many records
The ServiceNow custom actions plugin is community-sourced.
8.1. ServiceNow entity linking methods Copy linkLink copied to clipboard!
To view and manage ServiceNow incidents directly in Red Hat Developer Hub (RHDH), you must link an entity to your ServiceNow records. Linking ensures that incident data is accurately synchronized and visible within the relevant component or system.
Red Hat Developer Hub provides two methods for linking these entities. You can choose the method that best fits your organization’s security requirements and your ability to modify the ServiceNow schema.
8.1.1. Direct mapping (Backstage Entity ID column) Copy linkLink copied to clipboard!
The default method requires adding a custom column named backstage_entity_id to your ServiceNow incident table. You then manually or programmatically assign the specific RHDH entity reference (for example, component:default/my-service) to this column in ServiceNow.
Advantages:
- Highly secure and precise
- Ensures data is only exposed to the intended entity
Limitations:
- Requires a schema change in ServiceNow
- Requires manual data entry for each incident
8.1.2. Flexible mapping (Custom column mapping) Copy linkLink copied to clipboard!
The flexible mapping approach is an opt-in feature that allows you to use any existing column in your ServiceNow incident table to link to RHDH entities. Instead of creating a new column, you configure the ServiceNow plugin to look at an existing field (such as short_description, cmdb_ci, or a custom organizational ID) to match the entity.
Advantages:
- Does not require ServiceNow schema changes
- Faster to implement for organizations with strict ServiceNow governance
Limitations:
- Requires careful configuration to ensure that the search criteria in the chosen column are unique enough to prevent displaying unrelated incidents
8.1.3. Comparison of linking methods Copy linkLink copied to clipboard!
| Feature | Direct mapping | Flexible mapping |
|---|---|---|
| ServiceNow schema change | Required | Not required |
| Security level | High (strict matching) | Medium (dependent on column data) |
| Configuration complexity | Low (plugin side) | Medium (requires YAML mapping) |
| Ideal use case | New ServiceNow instances or high-security environments | Existing ServiceNow instances where schema changes are restricted |
8.1.4. Configure the ServiceNow plugin in the ConfigMap Copy linkLink copied to clipboard!
Update the Red Hat Developer Hub ConfigMap to enable the ServiceNow backend, frontend, and Scaffolder actions. This configuration defines the connection parameters and UI components required to integrate ServiceNow with your software catalog.
Prerequisites
-
You have provisioned a custom configuration by following the steps in Provisioning and using your custom Developer Hub configuration, including the section on authoring a custom
dynamic-plugins.yamlfile. - You have administrator access to an Red Hat OpenShift Container Platform cluster.
- Red Hat Developer Hub is installed on the cluster.
Procedure
-
Open your
Red Hat Developer HubConfigMap for editing. Add the ServiceNow backend and frontend plugin packages to the
dynamic-plugins.yamlsection, including the connection and UI configuration:kind: ConfigMap apiVersion: v1 metadata: name: rhdh-plugin-config data: dynamic-plugins.yaml: | includes: - dynamic-plugins.default.yaml plugins: # ----------------------------------------------------------------- # ... Your pre-existing custom dynamic plugins would be listed here # ----------------------------------------------------------------- # ServiceNow Backend Plugin - package: 'oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/backstage-community-plugin-servicenow-backend:<tag>' disabled: false pluginConfig: servicenow: instanceUrl: ${SERVICENOW_BASE_URL} basicAuth: username: ${SERVICENOW_USERNAME} password: ${SERVICENOW_PASSWORD} # ServiceNow Scaffolder Module / Actions - package: 'oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/backstage-community-plugin-scaffolder-backend-module-servicenow:<tag>' disabled: false pluginConfig: servicenow: baseUrl: ${SERVICENOW_BASE_URL} username: ${SERVICENOW_USERNAME} password: ${SERVICENOW_PASSWORD} # ServiceNow Frontend Plugin - package: 'oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/backstage-community-plugin-servicenow:<tag>' disabled: false pluginConfig: dynamicPlugins: frontend: backstage-community.plugin-servicenow: entityTabs: - path: /servicenow title: ServiceNow mountPoint: entity.page.servicenow - path: /my-servicenow title: My ServiceNow tickets mountPoint: entity.page.my-servicenow mountPoints: - mountPoint: entity.page.servicenow/cards importName: ServicenowPage config: layout: gridColumn: 1 / -1 height: 75vh if: anyOf: - hasAnnotation: servicenow.com/entity-id - mountPoint: entity.page.my-servicenow/cards importName: ServicenowPage config: layout: gridColumn: 1 / -1 height: 75vh if: allOf: - isKind: user - isMyProfilewhere:
<tag>Enter your RHDH version of Backstage and the plugin version, in the format
bs_<backstage-version>__<plugin-version>(note the double underscore delimiter). To find these versions, complete the following steps:- Find your Backstage version in the RHDH release notes preface.
Locate the plugin version in the Dynamic Plugins Reference guide. For example, for RHDH 1.10 based on Backstage 1.49.4, use the format
bs_1.49.4__<plugin-version>.TipTo ensure environment stability, use a SHA256 digest instead of a version tag. See Determining SHA256 Digests.
- Save the changes to the ConfigMap.
-
Wait for the RHDH Operator to redeploy the pods. The plugins are available once the pods are in a
Runningstate.
8.1.5. Link ServiceNow tickets to catalog entities Copy linkLink copied to clipboard!
The ServiceNow integration in Red Hat Developer Hub uses software catalog annotations to associate entities with ServiceNow records. By defining these identifiers, the ServiceNow plugin can retrieve and display relevant tickets and incidents directly within the component dashboard.
Prerequisites
- The ServiceNow plugin is installed and configured in your Red Hat Developer Hub instance.
- You have the unique identifier (such as a Service ID or Category) for the ServiceNow resource you want to link.
Procedure
-
Open the
catalog-info.yamlfile of the component you want to link to ServiceNow. Add the
servicenow.com/service-idannotation to themetadata.annotationssection.apiVersion: backstage.io/v1alpha1 kind: Component metadata: name: example-component annotations: servicenow.com/service-id: <your-service-id>servicenow.com/<field-name>-
Annotation pattern for linking to ServiceNow records. Replace
<field-name>with any ServiceNow table column name (such asservice-id,category,company). Theservicenow.com/prefix enables the ServiceNow tab. You can add multiple annotations to filter by different fields.
Optional: If your organization uses different categories to filter tickets, you can also add the category annotation:
metadata: annotations: servicenow.com/category: "software"- metadata.annotations.servicenow.com/category
- Specifies the ServiceNow category used to filter the displayed incidents.
-
Save the changes to
catalog-info.yamland commit them to your repository. - If the changes do not appear automatically, manually refresh the entity in the Red Hat Developer Hub catalog.
Verification
- Log in to your Red Hat Developer Hub and navigate to the Catalog.
- Select the component you updated.
- Select the ServiceNow tab.
- Confirm that the tab displays ServiceNow tickets or incidents associated with the provided ID.
8.1.6. Use ServiceNow scaffolder actions in software templates Copy linkLink copied to clipboard!
Add ServiceNow actions to your software templates to automate the creation, retrieval, and modification of ServiceNow records during the software scaffolding process.
Prerequisites
- You have configured the ServiceNow instance parameters in the Red Hat Developer HubConfigMap or app-config.yaml file.
- You have the required permissions to edit Software Templates in the source repository.
- You have registered the Software Template in the Red Hat Developer Hub catalog.
Procedure
- Open your software template YAML file.
-
In the
spec.stepssection, add the ServiceNow action that corresponds to your goal. Define the
tableNameand therequestBodycontaining the fields to populate or modify. The following example demonstrates how to use theservicenow:now:table:createRecordaction to generate an incident ticket:steps: - id: create-incident name: Create ServiceNow Incident action: servicenow:now:table:createRecord input: tableName: incident requestBody: short_description: "Printer is offline" description: "The office printer is not accessible via the network" severity: "3"Optional: To perform other operations, use the appropriate action ID and parameters:
Goal Action ID Key Input Parameters Delete a record
servicenow:now:table:deleteRecordtableName,sysIdModify a record
servicenow:now:table:modifyRecordtableName,sysId,requestBodyRetrieve a record
servicenow:now:table:retrieveRecordtableName,sysIdUpdate a record
servicenow:now:table:updateRecordtableName,sysId,requestBodyTipTo view the full schema and all available ServiceNow actions for your specific installation, navigate to Create > Installed Actions in the Red Hat Developer Hub interface.
8.1.7. ServiceNow configuration parameters Copy linkLink copied to clipboard!
The ServiceNow integration requires specific parameters in your configuration files to establish a connection between Red Hat Developer Hub and your ServiceNow instances. Use these parameters to define authentication methods, instance URLs, and UI layouts.
8.1.7.1. ServiceNow backend and frontend configuration Copy linkLink copied to clipboard!
Define the following parameters in the app-config.yaml file or the dynamic-plugins.yaml section of the Red Hat Developer Hub ConfigMap to enable the backend and frontend plugins.
| Parameter | Description | Requirement |
|---|---|---|
|
|
The base URL of your ServiceNow instance. For example, | Required |
|
| The service account username for Basic authentication. | Optional |
|
| The service account password for Basic authentication. | Optional |
|
|
The OAuth 2.0 grant type. Supports | Optional |
|
| The client ID for OAuth authentication. | Optional |
|
| The client secret for OAuth authentication. | Optional |
8.1.7.2. ServiceNow scaffolder configuration Copy linkLink copied to clipboard!
The ServiceNow Scaffolder module requires a separate configuration block. Note that this module uses baseUrl instead of instanceUrl.
| Parameter | Description | Requirement |
|---|---|---|
|
| The base URL of your ServiceNow instance. | Required |
|
| The service account username. | Required for Basic authentication |
|
| The service account password. | Required for Basic authentication |
8.1.7.3. Authentication examples Copy linkLink copied to clipboard!
The following examples demonstrate how to structure different authentication methods in your configuration.
8.1.7.4. Basic authentication example Copy linkLink copied to clipboard!
servicenow:
baseUrl: ${SERVICENOW_PROD_URL}
username: ${SERVICENOW_USER}
password: ${SERVICENOW_PASS}
8.1.7.5. OAuth with Client Credentials Copy linkLink copied to clipboard!
servicenow:
instanceUrl: ${SERVICENOW_INSTANCE_URL}
oauth:
grantType: client_credentials
clientId: ${SERVICENOW_CLIENT_ID}
clientSecret: ${SERVICENOW_CLIENT_SECRET}
8.1.7.6. OAuth with Password Grant Copy linkLink copied to clipboard!
servicenow:
instanceUrl: ${SERVICENOW_INSTANCE_URL}
oauth:
grantType: password
clientId: ${SERVICENOW_CLIENT_ID}
clientSecret: ${SERVICENOW_CLIENT_SECRET}
username: ${SERVICENOW_USER}
password: ${SERVICENOW_PASS}
8.1.7.7. Frontend UI configuration Copy linkLink copied to clipboard!
The frontend plugin configuration defines how ServiceNow data appears on component entity pages.
dynamicPlugins:
frontend:
backstage-community.plugin-servicenow:
entityTabs:
- path: /servicenow
title: ServiceNow
mountPoint: entity.page.servicenow
mountPoints:
- mountPoint: entity.page.servicenow/cards
importName: ServicenowPage
config:
layout:
gridColumn: 1 / -1
height: 75vh
8.2. Enable ServiceNow custom actions plugin in Red Hat Developer Hub Copy linkLink copied to clipboard!
To use ServiceNow custom actions, you must first activate the plugin.
Prerequisites
- Red Hat Developer Hub is installed and running.
- You have created a project in the Developer Hub.
Procedure
Add a
packagewith plugin name and update thedisabledfield in yourdynamic-plugins.yamlfile as follows:plugins: - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/backstage-community-plugin-scaffolder-backend-module-servicenow:<tag> disabled: false pluginConfig: servicenow: instanceUrl: ${SERVICENOW_BASE_URL} basicAuth: username: ${SERVICENOW_USERNAME} password: ${SERVICENOW_PASSWORD}where:
<tag>Enter your RHDH version of Backstage and the plugin version, in the format
bs_<backstage-version>__<plugin-version>(note the double underscore delimiter). To find these versions, complete the following steps:- Find your Backstage version in the RHDH release notes preface.
Locate the plugin version in the Dynamic Plugins Reference guide. For example, for RHDH 1.10 based on Backstage 1.49.4, use the format
bs_1.49.4__<plugin-version>.TipTo ensure environment stability, use a SHA256 digest instead of a version tag. See Determining SHA256 Digests.
NoteThe default configuration for a plugin is extracted from the
dynamic-plugins.default.yamlfile, however, you can use apluginConfigentry to override the default configuration.Set the following variables in your
app-config.yamlfile to access the custom actions:servicenow: # The base url of the ServiceNow instance. baseUrl: ${SERVICENOW_BASE_URL} # The username to use for authentication. username: ${SERVICENOW_USERNAME} # The password to use for authentication. password: ${SERVICENOW_PASSWORD}
8.3. Supported ServiceNow custom actions in Red Hat Developer Hub Copy linkLink copied to clipboard!
The ServiceNow custom actions enable you to manage records in the Red Hat Developer Hub.
The custom actions support the following HTTP methods for API requests:
-
GET: Retrieves specified information from a specified resource endpoint -
POST: Creates or updates a resource -
PUT: Modify a resource -
PATCH: Updates a resource DELETE: Deletes a resource- [GET] servicenow:now:table:retrieveRecord
Retrieves information of a specified record from a table in the Developer Hub.
The following table describes the input parameters:
Name Type Requirement Description tableNamestringRequired
Name of the table to retrieve the record from
sysIdstringRequired
Unique identifier of the record to retrieve
sysparmDisplayValueenum("true", "false", "all")Optional
Returns field display values such as
true, actual values asfalse, or both. The default value isfalse.sysparmExcludeReferenceLinkbooleanOptional
Set as
trueto exclude Table API links for reference fields. The default value isfalse.sysparmFieldsstring[]Optional
Array of fields to return in the response
sysparmViewstringOptional
Renders the response according to the specified UI view. You can override this parameter using
sysparm_fields.sysparmQueryNoDomainbooleanOptional
Set as
trueto access data across domains if authorized. The default value isfalse.The following table describes the output parameters:
Name Type Description resultRecord<PropertyKey, unknown>The response body of the request
- [GET]
servicenow:now:table:retrieveRecords Retrieves information about multiple records from a table in the Developer Hub.
The following table describes the input parameters:
Name Type Requirement Description tableNamestringRequired
Name of the table to retrieve the records from
sysparamQuerystringOptional
Encoded query string used to filter the results
sysparmDisplayValueenum("true", "false", "all")Optional
Returns field display values such as
true, actual values asfalse, or both. The default value isfalse.sysparmExcludeReferenceLinkbooleanOptional
Set as
trueto exclude Table API links for reference fields. The default value isfalse.sysparmSuppressPaginationHeaderbooleanOptional
Set as
trueto suppress pagination header. The default value isfalse.sysparmFieldsstring[]Optional
Array of fields to return in the response
sysparmLimitintOptional
Maximum number of results returned per page. The default value is
10,000.sysparmViewstringOptional
Renders the response according to the specified UI view. You can override this parameter using
sysparm_fields.sysparmQueryCategorystringOptional
Name of the query category to use for queries
sysparmQueryNoDomainbooleanOptional
Set as
trueto access data across domains if authorized. The default value isfalse.sysparmNoCountbooleanOptional
Does not run a select count(*) on the table. The default value is
false.The following table describes the output parameters:
Name Type Description resultRecord<PropertyKey, unknown>The response body of the request
- [POST]
servicenow:now:table:createRecord Creates a record in a table in the Developer Hub.
The following table describes the input parameters:
Name Type Requirement Description tableNamestringRequired
Name of the table to save the record in
requestBodyRecord<PropertyKey, unknown>Optional
Field name and associated value for each parameter to define in the specified record
sysparmDisplayValueenum("true", "false", "all")Optional
Returns field display values such as
true, actual values asfalse, or both. The default value isfalse.sysparmExcludeReferenceLinkbooleanOptional
Set as
trueto exclude Table API links for reference fields. The default value isfalse.sysparmFieldsstring[]Optional
Array of fields to return in the response
sysparmInputDisplayValuebooleanOptional
Set field values using their display value such as
trueor actual value asfalse. The default value isfalse.sysparmSuppressAutoSysFieldbooleanOptional
Set as
trueto suppress auto-generation of system fields. The default value isfalse.sysparmViewstringOptional
Renders the response according to the specified UI view. You can override this parameter using
sysparm_fields.The following table describes the output parameters:
Name Type Description resultRecord<PropertyKey, unknown>The response body of the request
- [PUT]
servicenow:now:table:modifyRecord Modifies a record in a table in the Developer Hub.
The following table describes the input parameters:
Name Type Requirement Description tableNamestringRequired
Name of the table to change the record from
sysIdstringRequired
Unique identifier of the record to change
requestBodyRecord<PropertyKey, unknown>Optional
Field name and associated value for each parameter to define in the specified record
sysparmDisplayValueenum("true", "false", "all")Optional
Returns field display values such as
true, actual values asfalse, or both. The default value isfalse.sysparmExcludeReferenceLinkbooleanOptional
Set as
trueto exclude Table API links for reference fields. The default value isfalse.sysparmFieldsstring[]Optional
Array of fields to return in the response
sysparmInputDisplayValuebooleanOptional
Set field values using their display value such as
trueor actual value asfalse. The default value isfalse.sysparmSuppressAutoSysFieldbooleanOptional
Set as
trueto suppress auto-generation of system fields. The default value isfalse.sysparmViewstringOptional
Renders the response according to the specified UI view. You can override this parameter using
sysparm_fields.sysparmQueryNoDomainbooleanOptional
Set as
trueto access data across domains if authorized. The default value isfalse.The following table describes the output parameters:
Name Type Description resultRecord<PropertyKey, unknown>The response body of the request
- [PATCH]
servicenow:now:table:updateRecord Updates a record in a table in the Developer Hub.
The following table describes the input parameters:
Name Type Requirement Description tableNamestringRequired
Name of the table to update the record in
sysIdstringRequired
Unique identifier of the record to update
requestBodyRecord<PropertyKey, unknown>Optional
Field name and associated value for each parameter to define in the specified record
sysparmDisplayValueenum("true", "false", "all")Optional
Returns field display values such as
true, actual values asfalse, or both. The default value isfalse.sysparmExcludeReferenceLinkbooleanOptional
Set as
trueto exclude Table API links for reference fields. The default value isfalse.sysparmFieldsstring[]Optional
Array of fields to return in the response
sysparmInputDisplayValuebooleanOptional
Set field values using their display value such as
trueor actual value asfalse. The default value isfalse.sysparmSuppressAutoSysFieldbooleanOptional
Set as
trueto suppress auto-generation of system fields. The default value isfalse.sysparmViewstringOptional
Renders the response according to the specified UI view. You can override this parameter using
sysparm_fields.sysparmQueryNoDomainbooleanOptional
Set as
trueto access data across domains if authorized. The default value isfalse.The following table describes the output parameters:
Name Type Description resultRecord<PropertyKey, unknown>The response body of the request
- [DELETE]
servicenow:now:table:deleteRecord Deletes a record from a table in the Developer Hub.
The following table describes the input parameters:
Name Type Requirement Description tableNamestringRequired
Name of the table to delete the record from
sysIdstringRequired
Unique identifier of the record to delete
sysparmQueryNoDomainbooleanOptional
Set as
trueto access data across domains if authorized. The default value isfalse.