简体   繁体   English

如何从Jenkins中的Web挂钩触发器中检索信息?

[英]How retrieve information from web-hook trigger in Jenkins?

I am using Gitlab community edition and I created a web-hook to my project which is trigger in push events. 我正在使用Gitlab社区版,并且为项目创建了一个Web挂钩,该挂钩在推送事件中触发。 This web-hook successfully trigger the Jenkins job but I need some additional information for my jenkins job like branch name and etc. Jenkins version 1.640. 此网络挂钩成功触发了Jenkins作业,但我需要一些其他信息来执行我的jenkins作业,例如分支名称等。Jenkins版本1.640。

I tried to follow this instruction: https://github.com/jenkinsci/gitlab-hook-plugin . 我试图遵循以下指示: https : //github.com/jenkinsci/gitlab-hook-plugin

I write this code to the job echo ${FULL_BRANCH_REFERENCE} but there is nothing in it. 我将此代码写入作业echo ${FULL_BRANCH_REFERENCE}但其中没有任何内容。

I used this url in the web-hook: http://xxxx:8080/job/gitlab/build (build_now did not work for me) 我在网络挂钩中使用了以下网址: http:// xxxx:8080 / job / gitlab / build (build_now对我不起作用)

Br,

I have found two solution. 我找到了两种解决方案。 I followed this description: https://github.com/jenkinsci/gitlab-hook-plugin . 我遵循以下描述: https : //github.com/jenkinsci/gitlab-hook-plugin First solution is using git-lab hook plug-in on Jenkins master. 第一个解决方案是在Jenkins master上使用git-lab hook插件。

  • Add Jenkins master URL on git-lab project web-hook. 在git-lab项目网络挂钩上添加Jenkins主URL。
  • And if we have a job that contains that git repo URL which are we added a web-hook. 如果我们有一个包含该git repo URL的工作,则添加了一个网络挂钩。 Git-Lab Web-hook plug-in will trigger all of those jobs. Git-Lab Web挂钩插件将触发所有这些作业。
  • And we can parameterize that jobs with some specific parameter (BRANCH, USERNAME, etc.) and now we can use these informations an a job. 而且我们可以使用某些特定参数(BRANCH,USERNAME等)对这些作业进行参数化,现在我们可以将这些信息用作作业。

Second solution could be Jenkins CI service which is not available on Git-Lab community edition. 第二种解决方案可能是Jenkins CI服务,该服务在Git-Lab社区版中不可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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