从Jenkins的gitlab webhook读取json负载

问题描述:

我按照此教程设置了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