Search code examples
azure-pipelines-release-pipelineservicenow-rest-api

How to create a ServiceNow Change Request as a step in TFS 2018 Release


I am trying to create a ServiceNow Change Request as one of the steps in my Release. I was trying to Agentless Phase step (Invoke Rest API: Post).

I found one article online that suggested to create a Generic Endpoint for ServiceNow. I tried that in the step failed, I'm sure I don't have it set up correctly.

2019-11-12T12:55:28.8833838Z POST https://xyzhelpdesk.service-now.com/api/now/table/change_request Response Code: 0 Response: An error was encountered while processing request.

Exception: {"error":{"message":"Exception while reading request","detail":"Cannot decode: java.io.StringReader@90f857"},"status":"failure"} Exception Message: The remote server returned an error: (400) Bad Request. (type WebException)

The endpoint has a username and password defined, but I think in the setup for Step I may need more information in the Header section.

enter image description here

I can create the CR via a Powershell script, I guess I could just use that but Not sure the correct way to go.

Basically I want to create a ServiceNow CR as part of my deployment process. Then there is a TFS plugin gated step that will check the status on the CR and when it's approves the process moves forward.

Who has examples ?

Thanks


Solution

  • Actually there is a built-in extension-- ServiceNow Change Management which provide by Microsoft almost fit your needs.

    It includes:

    • A release gate to hold the pipeline till the change management process signals implementation for a change request. You can create a new change request for every deployment or use an existing change request.
    • An agentless task to update a change request during the deployment process. It is typically used as the last task in the stage.

    However, this extension works only with Azure DevOps Services and Azure DevOps Server 2019 Update 1 onwards.. Not available to use on tfs2018. You could consider to upgrade your TFS to latest Azure DevOps Version.

    With TFS 2018, suggest you to use a powershell script to handle this. It's able to use ServiceNow and Azure DevOps Rest API. You could also take a look at great article blogs(similar for TFS):

    Integrating VSTS Release Management with ServiceNow using Deployment Gate for Change Management

    Implement an Azure DevOps Release Gate to ServiceNow