Get payload parameters in Jenkins

前端 未结 2 1538
野性不改
野性不改 2021-01-24 10:15

I\'m a newbie in Jenkins. I followed this help to implement Jenkins, Github and Webhook.

However, I\'m stuck in this problem. I want to get the payload parameters in Je

相关标签:
2条回答
  • 2021-01-24 10:30

    Easier way of doing this, without an extra library for parsing JSON, would be using the Generic Webhook Trigger Plugin in Jenkins.

    It can resolve any value from the JSON using JSONPath and assign it to variables available in the build.

    0 讨论(0)
  • 2021-01-24 10:42

    There are few steps that you should follow:

    1. Configure a web-hook in GitHub by which you will start communicating with Jenkins. This can be easily by going to your GitHub repository --> Setting --> Web-hooks.

    2. Make the entry for content-type as application/x-www-form-encoded.

    3. Select the event as Push event.
    4. Create a String parameter in Jenkins Server by the name of "payload".
    5. Following Step 3 GitHub would be able to wrap the content in this variable and send it to Jenkins.
    6. In Jenkins you can then read $payload variable when your build is kicked off.
    7. Parse the JSON using library of your choice

    References: How to process a github webhook payload in Jenkins? https://developer.github.com/webhooks/#payloads

    0 讨论(0)
提交回复
热议问题