【问题标题】:jenkins - triggering a build based on git commitjenkins - 触发基于 git commit 的构建
【发布时间】:2016-10-11 19:07:17
【问题描述】:

我正在尝试设置 jenkins,以便当检测到对 repo 的提交时,jenkins 中的构建会自动触发。 我一直在看这篇文章:How can I make Jenkins CI with git trigger on pushes to master?

但我不清楚我在哪里创建了 git hook “post-receive”。 到目前为止,我已经尝试了两个不同的地方:

  • 在 jenkins 服务器上,在我使用指定的 git 存储库设置这个新项目时为我自动创建的工作区文件夹中。
  • 在我用来为此存储库进行编码更改的开发人员工作站上。

两者都没有工作。 这是 post-receive 文件的样子:

me@jenkinslab:/var/lib/jenkins/jobs/test git repo/workspace/.git/hooks$ cat post-receive
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
curl http://10.1.1.11:8080/jenkins/git/notifyCommit?url=http://git.someinternaldomain.net/cgit/testing.git[&branches=branch1[,branch2]*][&sha1=<commit ID>]

除了创建此文件之外,在我的 jenkins 项目中,我在“构建触发器”部分下选中了“轮询 SCM”选项,但就计划定义而言没有任何内容。

你能告诉我我错过了什么吗?

请,谢谢。

【问题讨论】:

    标签: git github jenkins


    【解决方案1】:

    它在 git 服务器上运行。如果您使用的是 github.com,那么他们会在 UI 中为您设置好所有内容,您只需将 URL 放在正确的位置:您的存储库、设置、Webhooks 和服务。

    【讨论】:

    • 我刚刚在 git 服务器上创建了一个更新后挂钩,然后向 repo 提交了更改。 Jenkins 构建没有触发。只是想知道我可以在服务器上做什么来查看 git 钩子是否触发?
    【解决方案2】:

    这应该从 GIT 服务器上的 post-receive 挂钩(而不是 post-update)触发。

    您使用的是哪种 git 服务器?每种服务器(github、BitBucket 等)的解决方案可能不同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-14
      • 2015-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-19
      • 1970-01-01
      相关资源
      最近更新 更多