jenkins - Gitlab Jenkins Webhook 集成

标签 jenkins gitlab integration webhooks

所以目的是在推送到 Gitlab Repo 后触发 Jenkins 作业的构建,很简单吧?

下载 Gitlab 插件并设置项目后,仍然没有成功。我收到 403 错误。

最佳答案

经过一番尝试和错误后,我解决了这个问题:

我尝试的事情:
Web hook fails when Jenkins Anonymous user does not have job/build permission
Need to document GitLab -> Jenkins authentication setup How Do You Troubleshoot the GitLab Integration Webhook Error "Permission you need to have (but didn't) hudson.model.Hudson"?

这是我修复此错误所遵循的步骤

"Hook executed successfully but returned HTTP 403... You are authenticated as anonymous Groups that you are in: Permission you need to have (but didn't) hudson.model.Hudson.Read...which is implied by hudson.security.Permission.GenericRead..."

转到Jenkins>管理 Jenkins>配置
转到 Gitlab 部分并确保如下所示: Make sure Enable authentication for 'project' end-point is activated 设置完所有这些后,测试您的连接并确保成功。

在您的 Jenkins 项目中,转到配置 > 构建触发器并选择
当更改推送到 Gitlab 时进行构建。 Gitlab webhook URL...
另外,请确保在高级设置中生成 token

remember to generate the token in advanced settings
现在在 Gitlab 中转到您的项目>设置>集成 粘贴您在 Jenkins 项目中获得的 URL,以及在 Gitlab Build Triggers 部分中生成的 token ,删除 ssl 验证 Webhook conf

现在点击保存并测试你的钩子(Hook)
Test hook

您应该在 Gitlab 和 Jenkins 上收到 200 条成功消息,触发作业:
GitlabSuccess hook
Jenkins initiated job
如果情况并非如此,但您仍然收到 403,您可以执行以下操作:

在 Gitlab 中,将 Jenkins 用户添加到您的项目(您尝试从中触发 Webhook 的用户)。这次应该可以了!!! gitlab members

疑难解答

如果它仍然不起作用,您可以使用的另一个帮助器是向 Jenkins 添加记录器 转到Jenkins > 管理 Jenkins > 系统日志

  • 添加一个新的日志记录器。输入记录器的名称
  • 在输入字段中添加记录器。开始输入 gitlab 或 webhooks,
    与 Gitlab 或 webhooks 相关的任何内容:)
    loggers loggers conf 点击保存并开始查看当您从 Gitlab 中点击钩子(Hook)时发生了什么 logs

关于jenkins - Gitlab Jenkins Webhook 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55693706/

相关文章:

c# - 使用 C# 的 OneDrive API,以编程方式获取身份验证代码

jenkins - 对于 Jenkins Pipeline 插件,如何命名并行步骤以显示

ubuntu - GitLab 更新后 Nginx 无法启动

Java Python 集成

selenium - Jenkins 未运行 TestNG 测试

jenkins - stderr : fatal: Couldn't find remote ref $GERRIT_REFSPEC

Gitlab Markdown 工件链接

docker - gitlab-ci 为 docker 添加 --net=host 选项

c - 将 C 库与 Java、Ruby、Node、Python、Go、.NET 集成

magento 与 erp 和 crm 集成