microsoft / azure-pipelines-extensions

Collection of all RM and deployment extensions
http://www.visualstudio.com/explore/release-management-vs
MIT License
275 stars 425 forks source link

Service Now extension fails to update change in case of rerunning failed jobs #1154

Open vidarkongsli opened 1 year ago

vidarkongsli commented 1 year ago

I have set up the Service Now integration to run in a YAML pipeline where I update the change request upon completion of the stage. The change request is created by the ServiceNow Change management check on the environment. It works fine in the case that all the jobs in the stage run successfully.

But if I need to re-run failed jobs in the stage, it seems that it loses the stage id, and creates a new service now change instead of updating the existing one.

In the logs, I can observe that the GET request fired to get the change request number differs between the attempts.

First attempt:

GET https://<redacted>.service-now.com//api/now/table/change_request?sysparm_query=x_mioms_azpipeline_stage_id=c2f23cc9-b49b-5971-bdfa-5e6430153f6c^x_mioms_azpipeline_build_id=135294^x_mioms_azpipeline_stage_attempt=1&sysparm_fields=number,correlation_id
                Response Code: OK
                Response: {
  "result": [
    {
      "number": "CHG0033296",
      "correlation_id": "97670cb0-aae1-491b-89d7-431693f3ab7e"
    }
  ]
}

Then, on a later attempt:

GET https://<redacted>.service-now.com//api/now/table/change_request?sysparm_query=x_mioms_azpipeline_stage_id=9039092a-9198-5115-026a-7747c2953b49^x_mioms_azpipeline_build_id=135294^x_mioms_azpipeline_stage_attempt=3&sysparm_fields=number,correlation_id
                Response Code: OK
                Response: {
  "result": [
    {
      "number": "CHG0033298",
      "correlation_id": "f68627fc-fd2e-4cdb-9772-cc31fc74843a"
    }
  ]
}

Observe that:

I would expect the x_mioms_azpipeline_stage_id value to stay the same. What could be the cause of this?

Version information: