Service Management plays an integral role in managing, delivering, and auditing changes across the pipeline, as well as tracking incidents that occur as part of the software delivery lifecycle. In this blog series I will showcase four use cases for integrating a FlexDeploy pipeline with ServiceNow.
- FlexDeploy Service Management: Manual Ticket Entry
- FlexDeploy Service Management: Automated Ticket Creation for QA and Production
- FlexDeploy Service Management: One Ticket per Release Package
- FlexDeploy Service Management: Create Incident on Workflow Failure
The first three use cases focused on Change Management. Let’s shift gears and talk about another use case for Incident Management.
When a deployment fails someone will need to take action to resolve the issue. Often times organizations look to record these events by creating an incident in their Service Management system. This is quite simple to implement using FlexDeploy’s Outgoing Webhooks. An outgoing webhook offers functionality to subscribe to FlexDeploy events and take some action. Most often, but not always, this is used to integrate outbound to external tools.
For this use case I created an outbound webhook to subscribe to the Workflow Completed event. The webhook function is implemented in Groovy, and makes use of a rich library of functions that are available out of the box. This function extracts information from the event payload (project name, environment name, and workflow execution id), and formulates a map setting the values for an incident.
Line 16 uses the createIncident function to create the ServiceNow incident.
Notice that the event is for “Workflow Completed”, which means that it applies whether it was successful or failed. In this case we only want to create an incident if the status is failed. Here we can make use of a Filter and conditionally return whether the function should be called. If the event is due to a failed workflow request the function will be executed, otherwise it will not.
We did not implement it here, but we could also filter to exclude build workflow failures. As implemented above the function applies to workflows of all types.
To test this use case I intentionally introduced a deployment failure for one of the packages in my snapshot.
Reviewing the messages and logs for the webhook we can see that the event was fired and that it created an incident in ServiceNow.
In ServiceNow we can see the short description and description that we set in the Groovy function.
Outbound Webhooks enable endless integration scenarios, and this example shows just how easy it is to incorporate Incident Management into your DevOps pipelines.