I'm trying to automate the deployment of an Elasticsearch resource in the Elastic cloud, by invoking their REST API from within an Azure DevOps pipeline.
Invoking the API works fine using the InvokeRestAPI task, but now I want to use the information that is sent in the response to this API call. The documentation here says that this task can be used to invoke an HTTP API and parse the response but it doesn't give information about how to do that.
So far, I've tried to add a variable to my next job, based on a dependency, but that doesn't work:
- job: DeployES
dependsOn: GenerateTipTenantId
pool: server
variables:
tenantid: $[ dependencies.GenerateTipTenantId.outputs['GenerateGuid.faketenantid'] ]
steps:
- task: InvokeRESTAPI@1
name: EsRest
inputs:
<InvokeRESTAPI task inputs generated by the assistant>
- job: processDeployment
dependsOn: DeployES
pool:
vmImage: 'ubuntu-latest'
variables:
depid: $[ dependencies.DeployES.outputs['EsRest.Response.id'] ]
steps:
- script: echo $(depid)
name: echoid
I could probably replace the InvokeRestAPI by a 'regular' Powershell script, but the InvokeRestAPI task seemed easier to set up.
So the question is: how can I access the JSON object in the API's response and pass on part of it to the next job in my pipeline?