I’m working on automating a release pipeline using Azure DevOps and a Logic App. The goal is to initiate the release pipeline from the Logic App when an HTTP request is received and then to retrieve the output of an environment variable from the Azure DevOps pipeline to use it in the next stage of the Logic App.
Below is a summary of what I am trying to achieve and the issues I am encountering:
Steps:
-
Initiate Release Pipeline: Use a Logic App to start an Azure DevOps release pipeline.
-
Retrieve Environment Variable: Extract the output of a specific environment variable from the Azure DevOps pipeline.
-
Use Environment Variable in Logic App: Use the retrieved environment variable in the subsequent stage of the Logic App.
I have encountered a couple of issues that I’m unable to resolve:
-
Infinite Loop with Delay: I added a delay to wait for a pipeline stage to complete successfully, but it results in an infinite loop.
-
JSON Parsing Issue: I tried to retrieve output environment variables of the pipeline using a parse JSON stage, but it is not functioning as expected.
2
Answers
Below design worked for me:
then:
then:
Here I have taken Result in Compose to get the result of build pipeline, take it and then use Parse Json as you will get to know what is the type of output/result it is giving and then use respective schema according to it.
Output:
The issue is not with design as the design worked for me.
The output variable set using logging command is only available to the next tasks during running time. You can get it via the REST API, that’s why you can’t retrieve it in your Parse JSON action.
As a workaround, you can create a variable group in Azure DevOps and use it to store your target variable. See the detailed steps below.
Data
.Data
with your output variable’s value.Create a parameter in your Logic app and add the
newtoken
you get.Add a HTTP action after Delay action and call REST API Variablegroups – Get to get the value of the variable.
https://dev.azure.com/{OrgName}/{ProjectName}/_apis/distributedtask/variablegroups/{VariableGroupId}?api-version=7.1-preview.2
GET
Then you can see the variable in the response body of HTTP action, and you can retrieve the variable and use it in the next actions.