How to trigger the azure devops build pipeline using azure logic app

Syed Aman 1 Reputation point
2023-06-15T21:54:24.85+00:00

I am trying to setup a slack integration to trigger the azure build pipeline using azure logic app.

I have completed the setup for slack command to point to logic app http request endpoint url. however i am unable to extract the parameter value passed with slack command as argument and set that as parameter to pass it to queue a build (azure devops)

Slack command:

/trigger-build ansible_verbosity=2 pa__name=max6 pa__tag=deploy pa_deployment_override=true version=5.8.3

Below are the HTTP request received output

{
    "headers": {
        "Accept": "application/json,*/*",
        "Accept-Encoding": "gzip,deflate",
        "Host": "prod-54.southeastasia.logic.azure.com",
        "User-Agent": "Slackbot,1.0,(+https://api.slack.com/robots)",
        "X-Slack-Signature": "v0=52408903d16175bc6a3e2eca1dd03a720b50adfb1bd3abac79fc49c9f6e8e256",
        "X-Slack-Request-Timestamp": "1686864764",
        "Content-Length": "554",
        "Content-Type": "application/x-www-form-urlencoded"
    },
    "body": {
        "$content-type": "application/x-www-form-urlencoded",
        "$content": "dG9rZW49OEl3djZ0ZkJ6bmp4SXdwMEt0Rlk3dUt6JnRlYW1faWQ9VDA1QjFGWktURlYmdGVhbV9kb21haW49bGVhcm5henVyZWNsb3VkY29pbiZjaGFubmVsX2lkPUMwNUJSQjQzWTlXJmNoYW5uZWxfbmFtZT1hdXRvbWF0aW9uJnVzZXJfaWQ9VTA1QlJBWkxONTYmdXNlcl9uYW1lPXN5ZWQuYW1hbiZjb21tYW5kPSUyRnRyaWdnZXItYnVpbGQmdGV4dD1hbnNpYmxlX3ZlcmJvc2l0eSUzRDIrcGFfaW50ZXJuYWxfbmFtZSUzRG1heDYrcGFfZGVwbG95X3RhZyUzRGRlcGxveStwYV9kZXBsb3ltZW50X3BhdGNoX292ZXJyaWRlJTNEdHJ1ZSt2ZXJzaW9uJTNENS44LjMmYXBpX2FwcF9pZD1BMDVCMU41N0Y4QSZpc19lbnRlcnByaXNlX2luc3RhbGw9ZmFsc2UmcmVzcG9uc2VfdXJsPWh0dHBzJTNBJTJGJTJGaG9va3Muc2xhY2suY29tJTJGY29tbWFuZHMlMkZUMDVCMUZaS1RGViUyRjU0MzUyMDEzNzAwMTglMkZPaXhsYlEzUW1vUm96aENNc3MwZ2tTYjkmdHJpZ2dlcl9pZD01NDMyMjYyNDMyMTk3LjUzNzU1NDM2NzM1MzkuMDNlOWEwNWI5YjBhOWU5NWMwZTRjMTJhOGE3ZmM2ZmM=",
        "$formdata": [
            {
                "key": "token",
                "value": "8Iwv6tfBznjxIwp0KtFY7uKz"
            },
            {
                "key": "team_id",
                "value": "T05B1FZKTFV"
            },
            {
                "key": "team_domain",
                "value": "learnazurecloudcoin"
            },
            {
                "key": "channel_id",
                "value": "C05BRB43Y9W"
            },
            {
                "key": "channel_name",
                "value": "automation"
            },
            {
                "key": "user_id",
                "value": "U05BRAZLN56"
            },
            {
                "key": "user_name",
                "value": "syed.aman"
            },
            {
                "key": "command",
                "value": "/trigger-build"
            },
            {
                "key": "text",
                "value": "ansible_verbosity=2 pa_internal_name=max6 pa_deploy_tag=deploy pa_deployment_patch_override=true version=5.8.3"
            },
            {
                "key": "api_app_id",
                "value": "A05B1N57F8A"
            },
            {
                "key": "is_enterprise_install",
                "value": "false"
            },
            {
                "key": "response_url",
                "value": "https://hooks.slack.com/commands/T05B1FZKTFV/5435201370018/OixlbQ3QmoRozhCMss0gkSb9"
            },
            {
                "key": "trigger_id",
                "value": "5432262432197.5375543673539.03e9a05b9b0a9e95c0e4c12a8a7fc6fc"
            }
        ]
    }
}

The parameters which I had passed are stored as "text".

{
                "key": "text",
                "value": "ansible_verbosity=2 pa_internal_name=max6 pa_deploy_tag=deploy pa_deployment_patch_override=true version=5.8.3"
            },

Need Help in extracting the values and setting it as a parameters to pass it to queue a build (azure devops)

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 25,241 Reputation points Microsoft Employee Moderator
    2023-06-20T08:25:56.9933333+00:00

    Hello Syed Aman

    Based on the shared issue description, I have understood that you are trying to queue DevOps build through logic app and by pulling the specific Key value of text from the HTTP request trigger output.

    To test this, we have created a consumption-based logic app using the above shared JSON as Input and thereby using the ParseJSON action and For_each loop to pull the text parameter key value.

    Here is screenshot of our logic app :

    User's image

    Here are the expressions that we have used in our logic app:

    1. In Condition action : items('For_each')?['key] = "test"
    2. Under true branch and in Set Variable action : items('For_each')?['value']

    Here is the sample output for your reference :

    User's image

    User's image

    Feel free to reach back to me if you have any further questions on this.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.