从 Jenkins 中的 gitlab webhook 读取 json 有效负载 [英] Read json payload from gitlab webhook in Jenkins

查看:29
本文介绍了从 Jenkins 中的 gitlab webhook 读取 json 有效负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照这个 tutorial 设置了一个 Jenkins 作业,以便在任何时候运行推送到 gitlab 存储库.我测试了 webhook,我可以看到作业被触发了.但是,我在有效负载中看不到任何内容.

I followed this tutorial to setup a Jenkins job to run whenever a push is made to the gitlab repository. I tested the webhook and I can see that the job is triggered. However, I don't see anything in the payload.

只是想知道,是否有人尝试过读取从 gitlab webhook 收到的有效负载?

Just wondering, if anyone has ever tried to read the payload received from gitlab webhook?

推荐答案

Jenkins Gitlab插件这些 POST 参数 发送给 Jenkins事件发生在 Gitlab 存储库中.

Jenkins Gitlab Plugin sends these POST parameters to Jenkins whenever any event occurs in the Gitlab repo.

您可以在 Jenkins 控制台中添加 env 以获取所有 Gitlab 参数导出到 Jenkins 环境中的内容.然后就可以打印或使用所需的变量了.

You can add env in the Jenkins console to get what all Gitlab parameters are exported to the Jenkins environment. Then you can print or use the required variables.

例如

echo $gitlabSourceRepoURL
echo $gitlabAfter
echo $gitlabTargetBranch
echo $gitlabSourceRepoHttpUrl
echo $gitlabMergeRequestLastCommit
echo $gitlabSourceRepoSshUrl
echo $gitlabSourceRepoHomepage
echo $gitlabBranch
echo $gitlabSourceBranch
echo $gitlabUserEmail
echo $gitlabBefore
echo $gitlabSourceRepoName
echo $gitlabSourceNamespace
echo $gitlabUserName

这篇关于从 Jenkins 中的 gitlab webhook 读取 json 有效负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆