Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research which tasks can be implemented using HttpRequest or HttpRequestChain execution #55

Open
2 tasks
christian-kreuzberger-dtx opened this issue Dec 2, 2021 · 0 comments

Comments

@christian-kreuzberger-dtx
Copy link
Contributor

christian-kreuzberger-dtx commented Dec 2, 2021

I found this in the Azure DevOps examples:
https://github.com/microsoft/azure-pipelines-extensions/blob/78bf251236c84c4da622c125764b7e7434e98a2a/Extensions/ServiceNow/Src/Tasks/UpdateChangeRequest/UpdateChangeRequestV2/task.json#L118-L162

Basically it means that instead of

  "execution": {
    "Node10": {
      "target": "index.js",
      "argumentFormat": ""
    }
  }

it is possible to use a http request chain, e.g.:

"Execute": [{
          "RequestInputs": {
            "EndpointId": "$(ServiceNowConnection)",
            "EndpointUrl": "$(endpoint.url)/api/now/table/change_request?sysparm_query=number=$(ChangeRequestNumber)&sysparm_fields=number,correlation_id",
            "Method": "GET",
            "Headers": "{\"Content-Type\":\"application/json\", \"Accept\":\"application/json\"}",
            "WaitForCompletion": "false",
            "Expression": "eq(count(root['result']), 1)"
          },
          "ExecutionOptions": {
            "OutputVariables": "{\"CHANGE_REQUEST_NUMBER\" :  \"jsonpath('$.result[0].number')[0]\", \"CHANGE_CORRELATION_ID\" :  \"jsonpath('$.result[0].correlation_id')[0]\"}",
            "SkipSectionExpression": "eq(isNullOrEmpty(taskInputs['ChangeRequestNumber']), true)"
          }
        },

 {
          "RequestInputs": {
            "EndpointId": "$(ServiceNowConnection)",
            "EndpointUrl": "$(endpoint.url)/api/now/import/x_mioms_azpipeline_change_request_import",
            "Method": "POST",
            "Body": "{\"u_number\": \"$(CHANGE_REQUEST_NUMBER)\",\"u_correlation_id\": \"$(CHANGE_CORRELATION_ID)\",\"u_work_notes\": \"$(WorkNotes)\"{{#equals UpdateStatus 'true'}},\"u_state\": \"$(NewStatus)\"{{#equals '$(NewStatus)' '3' 1}}, \"u_close_code\": \"$(CloseCode)\", \"u_close_notes\": \"$(CloseNotes)\"{{/equals}}{{/equals}}{{#if otherParameters}}{{toCommaSeparatedKeyValueList otherParameters true}}{{/if}} }",
            "Headers": "{\"Content-Type\":\"application/json\", \"Accept\":\"application/json\"}",
            "WaitForCompletion": "false",
            "Expression": "eq(jsonpath('$.result[0].status')[0], 'updated')"
          }
        }

Another way I found is

  "execution": {
    "HttpRequest": {
      "Execute": {
        "EndpointId": "$(XYZServerConnection)",
        "EndpointUrl": "$(endpoint.url)$(urlSuffix)",
        "Method": "GET",
        "Headers": "{\"Content-Type\":\"application/json\", \"Accept\":\"application/json\"}",
        "WaitForCompletion": "false",
        "Expression": "$(successCriteria)"
      }
    }

IMO it could be viable to do this for certain tasks (e.g., creating a service, creating a project, sending a CloudEvent, etc...), which would save us some lines of code.

Definition of Done

  • Research which tasks would be elegible for this execution (by trying it out)
  • Investigate the disadvantages of this approach
@christian-kreuzberger-dtx christian-kreuzberger-dtx changed the title Research which tasks can be implemented using HttpRequestChain execution Research which tasks can be implemented using HttpRequest or HttpRequestChain execution Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant