git - 无法使用 'Poll SCM' 和 Git notifyCommit 选项触发构建

标签 git jenkins githooks

我们使用 Jenkins (1.614) 并使用 Git 作为版本控制工具。 Git 插件版本是 2.3.5。我试图在每次 checkin 后触发构建,因为连续轮询的成本太高。我尝试了各种链接中描述的以下方法,但它不起作用:

  1. 启用“轮询 SCM”并分配一个虚拟值。我也尝试过不分配任何值。
  2. 在接收后 Hook 中添加了以下行:

curl http://jenkins_url:9099/jenkins/git/notifyCommit?url=ssh://gitolite@git_server/TestRepo

  • 现在,如果我提交一些更改,我会在推送过程中收到以下消息:
  • $ git push origin release-test
    Counting objects: 20, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 308 bytes | 0 bytes/s, done.
    Total 3 (delta 1), reused 0 (delta 0)
    remote: Commit ID: 3a9cddadasd
    remote: Returning result 0
    remote:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    remote:                                  Dload  Upload   Total   Spent    Left  Speed
    remote: 124   124  124   124    0     0     30      0  0:00:04  0:00:04 --:--:--   497
    remote: Scheduled polling of Poll_Job
    remote: No Git consumers using SCM API plugin for: ssh://gitolite@git_server/TestRepo

  • 当我查看 Git 轮询日志时,我注意到以下内容:
  • Started on Jun 10, 2015 6:42:04 PM
    No existing build. Scheduling a new one.
    Done. Took 0 ms
    Changes found

    我确实看到每次此类轮询后构建 # 都会增加几秒钟,但“构建历史记录”仍然为空,如下所示。不会执行构建过程中的任何步骤。

    enter image description here

    有任何输入说明为什么构建没有按预期触发吗?

    最佳答案

    查看构建“Git 轮询日志”,它可能会指出问题所在。我遇到了类似的问题,其中由 Git 的“Poll SCM”触发的 Maven 作业停止触发新的构建。显然原因是:

    ERROR: Failed to record SCM polling ... undefined method `add' for nil:NilClass at Jenkins::Model::Build.initialize(C:/Jenkins/plugins/nodeofflinenotification/ ...

    然后我注意到“Node Offline notification Plugin”已被弃用,因此我卸载了它(并安装了“Mail Watcher Plugin”),SCM 轮询再次工作。

    关于git - 无法使用 'Poll SCM' 和 Git notifyCommit 选项触发构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30759944/

    相关文章:

    docker - 这就是我在jenkins调用的shell脚本中构建镜像和部署的方式?

    git - 在 Jenkins 中使用多个 git 分支进行 Sonar 分析

    git - 如何使用 github webhooks 阻止特定的推送?

    git post-receive hook 和一次推送多个提交

    git - 如何在服务器端创建一个git钩子(Hook),以便在收到推送后 pull (在需要root权限才能修改的路径中)?

    linux - 使用符号链接(symbolic link)及其内容对 linux 文件夹进行版本控制

    Git master 和开发不同步

    git 错误无法将 Commit 作为内置处理

    git - 如何在 Git 中查看分支的远程更改?

    continuous-integration - jenkins 中的几个 checkstyle 报告