git Jenkins 和 Gitlab:Webhook 未运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21782950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:44:09  来源:igfitidea点击:

Jenkins and Gitlab: Webhook isn't running

gitjenkinscontinuous-integrationgitlab

提问by davidpaquipalla

I have a couple of servers:

我有几台服务器:

  1. Jenkins
  2. Gitlab
  1. 詹金斯
  2. GitLab

On gitlab, I have a webhook:

在 gitlab 上,我有一个 webhook:

On Push events -> http://{jenkinsIP}:8080/gitlab/build_now

On Jenkins, I have a job:

在詹金斯,我有一份工作:

Source Code Management:

Git:

Repository URL : git@{GitlabIP}:{Gitlabgroup}/{project}.git (copy from gitlab)

Credential: key-pair working

Branches to build: */master

Repository browser: gitlab

url: http://{GitlabIP}/{Gitlabgroup}/{project}

Version: 6.5.1

Poll SCM

Schedule H/1 * * * *

源代码管理:

吉特:

Repository URL : git@{GitlabIP}:{Gitlabgroup}/{project}.git (copy from gitlab)

凭证:密钥对工作

要构建的分支:*/master

存储库浏览器:gitlab

url: http://{GitlabIP}/{Gitlabgroup}/{project}

版本:6.5.1

轮询单片机

Schedule H/1 * * * *

Any clue why Jenkins isn't running the job?

任何线索为什么詹金斯没有运行这项工作?

回答by Javen

On Jenkins, you should disable "Poll SCM"and set the "Branches to build"to "master"(not "*/master")

在 Jenkins 上,您应该禁用"Poll SCM"并设置"Branches to build""master"(not "*/master")

回答by vnc

You don't have to put a schedule in the "poll SCM" box, it's enough to enable this option. (even if jenkins warns you (yellow), that nothing will ever happen). Then, the webhook at gitlab does his job. I configured my stuff following http://juristr.com/blog/2014/01/git-flow-jenkins-gitlab/and it works

您不必在“轮询 SCM”框中放置时间表,启用此选项就足够了。(即使詹金斯警告您(黄色),也不会发生任何事情)。然后,gitlab 的 webhook 完成他的工作。我按照http://juristr.com/blog/2014/01/git-flow-jenkins-gitlab/配置了我的东西并且它有效

回答by Carlos Cavero

The GitLab plugin is awesome. Follow the instructions and everything works like a charm. It is also described how to send back information to GitLab from jenkins: https://github.com/jenkinsci/gitlab-plugin/wiki/Setup-Example. I faced problems with the GitLab webhook to jenkins due to https connection (500 error). I fixed it including the SSL cert in the GitLab server: https://gitlab.com/gitlab-org/gitlab-ce/issues/2681

GitLab 插件很棒。按照说明操作,一切都像魅力一样。还描述了如何从 jenkins 将信息发送回 GitLab:https: //github.com/jenkinsci/gitlab-plugin/wiki/Setup-Example。由于 https 连接(500 错误),我遇到了与 jenkins 的 GitLab webhook 问题。我修复了它,包括 GitLab 服务器中的 SSL 证书:https://gitlab.com/gitlab-org/gitlab-ce/issues/2681

回答by foudfou

There could be multiple problems.

可能有多个问题。

For one, I don't see why you create a WebHook on Gitlab, and use Poll SCM on Jenkins: either use Trigger builds remotelyon Jenkins with a WebHook on Gitlab, or Poll SCMon Jenkins but then also enable some Credentialsfor the git repo on Jenkins' side (most probably SSH deploy key).

一方面,我不明白你为什么要在 Gitlab 上创建一个 WebHook,并在 Jenkins 上使用 Poll SCM:要么在 Jenkins 上远程使用Trigger 构建,在 Gitlab 上使用 WebHook,要么在 Jenkins 上使用Poll SCM但也为 git启用一些凭据Jenkins 一侧的 repo(很可能是 SSH 部署密钥)。

Other than that, builds are actually triggered if the git repo changes: what branches are configured on Jenkins' side ?

除此之外,如果 git repo 更改,实际上会触发构建:在 Jenkins 一侧配置了哪些分支?

Note, I haven't tested the Gitlab plugin for Jenkins yet.

请注意,我还没有为 Jenkins 测试 Gitlab 插件。