Azure-devops-docs: ServiceNow Gate Output Variable does not seem to work when referencing PREDEPLOYGATE.gate1.CHANGE_REQUEST_NUMBER in Post Deployment Gate

Created on 3 Jun 2019  Â·  8Comments  Â·  Source: MicrosoftDocs/azure-devops-docs

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)

Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 devops-cictech devopprod doc-bug

Most helpful comment

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

All 8 comments

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:

  • Single Stage
  • PreDeploy gate to create change and updated the Output Variables Reference to PTL (the UI shows the following 2 variables PTL.CHANGE_REQUEST_NUMBER and PTL.CHANGE_SYSTEM_ID
  • Next I have a Powershell task to print with this Write-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 behaviour
  • I disabled the step and then tried adding an agentless job with an update service now task which seems to understand and expand the PREDEPLOYGATE.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
  • then I tried this {"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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Naphier picture Naphier  Â·  3Comments

sevaa picture sevaa  Â·  3Comments

LennartAJansson picture LennartAJansson  Â·  3Comments

dtamai picture dtamai  Â·  3Comments

KacperMucha picture KacperMucha  Â·  3Comments