Jenkins 通知轮询构建失败,并显示“URI ssh://path 没有 git 消费者”

Abd*_*ull 8 ssh git jenkins

每当我的 Jenkins 收到有关我的存储库foo的新 git 提交的通知时,我都会在触发客户端上收到以下日志/错误响应:

Scheduled polling of foo
No git consumers for URI ssh://git@localhost:9777/path/to/foo.git
Run Code Online (Sandbox Code Playgroud)

这个失败的通知不会开始构建。使用手册“立即构建”开始成功构建。

设置

  • 我让 Jenkins 实例监听localhost:8666.
  • 我让 SSH 守护进程监听localhost:9777.
  • 在 Jenkins 中,我有一个基于 git 的 Maven 项目:
    • “Maven 项目名称”是foo
    • “Git 存储库 URL”是ssh://git@localhost:9777/path/to/foo.git.
  • 在那个裸仓库中,我有一个hooks/post-receive包含内容的钩子文件:

.

# this is file post-receive
curl http://localhost:8666/git/notifyCommit?url=ssh://git@localhost:9777/path/to/foo.git
Run Code Online (Sandbox Code Playgroud)

这种基于提交的通知过去运行良好。我有一种感觉,一旦我从标准 SSH 端口 22 移动到非标准 9777,它就会停止正常工作。

我该怎么做才能让提交通知导致构建触发器成功?


可能相关的源代码文件:

Fil*_*ale 5

将钩子连接到 Jenkins 时要记住的事情:

  1. Poll SCM将 Build Triggers 中的选项加厚,将“schedule”文本区域留空

  2. url=xxx参数必须与作业配置中指定的“存储库 URL”匹配。如果它以 ssh:// 为前缀,则应将其保留在通知调用中

  3. 别忘了push a change to the repo你配置!要验证您有更改: http://jenkins-url:jenkins-port/job/JOB-NAME/scmPollLog/应在最后一行包含“找到的更改”。

来源:Git 插件文档

  • #3 比看起来更重要。如果您的作业未配置为构建每个分支,请检查您是否推送到正确的分支。至少这就是让我在两个小时的大部分时间里寻找错误的原因。即使构建作业被成功触发,我仍然在推送时收到“URI 没有 git 消费者”消息。 (2认同)

小智 -1

您不需要 ssh:// 部分。

尝试:

curl http://localhost:8666/git/notifyCommit?url=git@localhost:9777/path/to/foo.git