简体   繁体   中英

Gitlab CI Webhook - How to see JSON Payload

I am sending a JSON payload to my Gitlab CI Pipeline, via the Gitlab Webhook, as the Trigger.

The trigger works, however I need to be able to parse the JSON sent via the Web hook, as it contains the values, for my script's variables.

Question:

Is there a way, I can use the '.gitlab-ci.yml' file, and pull out the content sent, via the Web hook's POST?

Is it possible for a Gitlab Webhook to use a variable that contains the JSON payload, and pass the variable and its content, into the '.gitlab-ci.yml' file?

I am open to any solution.

The end goal would be to parse the JSON sent in the Web Hook POST, with my Powershell scripts, and pass the parsed JSON values to my Variables, as their inputs.

Thank you

Similar questions have been asked, with no updated answer Read webhook payload in Gitlab CI

You can use the gitlab-ci pipeline variables to pass the values to your '.gitlab-ci.yml' file. You can check here for more info: https://docs.gitlab.com/ee/ci/triggers/#making-use-of-trigger-variables

I guess for the json format, you should enter something similar to the body part of the request:

Content-type: application/json
    {
    "variables[var1]":"value1"
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM