如何让 Jenkins 自动为 Pipeline 作业添加 webhook?

x-y*_*uri 5 github webhooks jenkins jenkins-pipeline

我已经为 Jenkins 添加了凭据,以便能够添加 Webhook。为此,我做了以下操作:

\n\n
    \n
  1. 在 GitHub 上生成个人访问令牌,repoadmin:repo_hook具有范围。
  2. \n
  3. 添加了Secret text带有相应令牌的凭据。
  4. \n
  5. 使用上一步中的凭据添加了 GitHub Server Manage Jenkins > Configure System
  6. \n
\n\n

但是当我创建管道作业时,我在系统日志中看到:

\n\n
GitHub webhooks activated for job p1 with [] (events: [PUSH])\n
Run Code Online (Sandbox Code Playgroud)\n\n

通过 Freestyle 项目我得到:

\n\n
GitHub webhooks activated for job fsp1 with [GitHubRepositoryName[host=github.com,username=user,repository=repo]] (events: [PUSH])\nPING webhook received from repo <https://github.com/user/repo>!\n
Run Code Online (Sandbox Code Playgroud)\n\n

对于 Freestyle 项目,我做了以下工作:

\n\n
    \n
  1. “源代码管理”选项卡上选择“Git”,指定存储库 URL 和凭据(用户名和密码)。
  2. \n
  3. 检查了GITScm 轮询的 GitHub 挂钩触发器
  4. \n
\n\n

对于管道作业:

\n\n
    \n
  1. 检查了GitHub 项目并指定了存储库 URL。
  2. \n
  3. \xef\xbf\xbc已检查GITScm 轮询的 GitHub 挂钩触发器
  4. \n
\n\n

我缺少什么?

\n

小智 3

要使其添加 Webhook(创建管道后):

  • 手动运行管道一次
  • 重新注册 webhooks(管理 Jenkins > 配置系统 > GitHub 插件 > 高级(用铅笔标记)> 为所有作业重新注册挂钩)

这是一个已知问题。您可以在这里查找:https://issues.jenkins.io/browse/JENKINS-37217