It seems that the $(PREDEPLOYGATE.gate1.CHANGE_REQUEST_NUMBER) does not seam work when being picked up in a post deployment gate to modify the Change Request.
With the setup replicated exactly in the documentation it doe snot seem to work ?
Is this documentation complete, current and accurate:
https://github.com/Microsoft/azure-pipelines-extensions/tree/master/Extensions/ServiceNow/Src
Additionally per step 3, the image shows the service now change as a task, when this is part of the Stage Pre/Post Deployment Gates
we get this error in the PostDeployment Gate pipeline log
Exception Message: Variable with name PREDEPLOYGATE.gate1.CHANGE_REQUEST_NUMBER could not be found for the given service connection. (type ServiceEndpointException)
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
I'm experiencing the exact error in the same scenario as explained above
The variable output from the gate is currently available to agentless jobs only. In order to access the variable on other jobs, you'll need to use RM REST APIs to update a release variable from the agentless job. We'll look to have an extension to do the same and help you.
One assumes we can configure the pipeline to run agent-less but the job/tasks to run on a agent ?
It would be most helpful if the online documentation was maintained - such that we’re not all shooting around in the dark!!
I have now tried the following:
PTL (the UI shows the following 2 variables PTL.CHANGE_REQUEST_NUMBER and PTL.CHANGE_SYSTEM_IDWrite-Host "1 $(PREDEPLOYGATE.PTL.CHANGE_REQUEST_NUMBER)" this raised an error The term 'PREDEPLOYGATE.PTL.CHANGE_REQUEST_NUMBER' is not recognized as the name... base on your comment it looks like this is expected behaviourPREDEPLOYGATE.PTL.CHANGE_REQUEST_NUMBER but it seems that variable expansion in the Additional change request parameters arent working. I tried passing this {"u_start_date":"$(PlannedStartDateTime)","u_end_date":"$(PlannedEndDateTime)","u_description":"Updated Description","u_reason_for_change":"Updated Reason"} and got an ignored status from service now for that change with status_message : No field values changed{"u_start_date":"2019-08-03T11:12:42","u_end_date":"2019-08-04T11:12:42","u_description":"Updated Description","u_reason_for_change":"Updated Reason"} resulted in error_message : Unable to format 8/4/2019 11:12:42 AM using format string yyyy-MM-dd HH:mm:ss for field end_date How do I pass Datetimes for Release Schedule and how do I get it to expand variables in the Additional change request parameters
@shashban any updates on this would be appreciated thanks
As discussed offline, the gate output variables are only available to Agentless jobs in the deployment process. You'll need to write the variable value to release variable using an agentless task and use it in post-deployment gate.
As an alternative, you can query the change using release.releaseId in the post deployment gate
Hi @shashban
You'll need to write the variable value to release variable using an agentless task and use it in post-deployment gate.
How exactly do you do this as there is no Powershell available in an Agentless Job
I opened a ticket with to basically the same thing and got the following information...
Can you share details about your use case? What do you want to do with string?
As of now we don't have direct method to convert JSON to string. Although Using >HttpRequestChain handler we have written some tasks where we are passing object from 1 request >to another. Task using HttpRequestChain
The task above makes a call to get the current release pipeline and then posts it back with an updated release body that contains the release variable. You can chain the agentless task above with this ServiceNow task to accomplish the same thing.
Edit: @eugeneniemand
Most helpful comment
Hi @shashban
How exactly do you do this as there is no Powershell available in an Agentless Job