获取詹金斯的有效载荷参数 [英] Get payload parameters in Jenkins
问题描述
我是詹金斯的新手.我遵循了这个帮助来实施Jenkins,Github和Webhook.
I'm a newbie in Jenkins. I followed this help to implement Jenkins, Github and Webhook.
但是,我陷入了这个问题.我想在Jenkins中获取有效负载参数,以从有效负载json检查信息,例如更改,操作....
However, I'm stuck in this problem. I want to get the payload parameters in Jenkins to check information such as changes, actions...from payload json.
我写了一些脚本进行测试. ACTION
和$payload
始终返回空
I wrote some script to test. ACTION
and $payload
always returns empty
# !/bin/bash
ACTION=`echo $payload | php -r '$data = file_get_contents("php://stdin"); $json = json_decode($data, true); echo $json["action"];'`
我阅读了一些教程,但是没有成功.
I read some tutorials but unsuccessfully.
推荐答案
您应该遵循以下几个步骤:
There are few steps that you should follow:
-
在GitHub中配置一个Web挂钩,您将通过该挂钩开始与Jenkins进行通信.转到您的GitHub存储库->设置-> Web-hooks可以很容易地做到这一点.
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.
将内容类型的条目设置为application/x-www-form-encoded.
Make the entry for content-type as application/x-www-form-encoded.
参考: 如何在Jenkins中处理github webhook有效负载?一个> https://developer.github.com/webhooks/#payloads
References: How to process a github webhook payload in Jenkins? https://developer.github.com/webhooks/#payloads
这篇关于获取詹金斯的有效载荷参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!