我在 Gitea scm 有一份自由式工作。我在 Gitea 上设置了 webhook,但是当其他分支发生变化时,jenkins 将重建一次。如何仅在推送到主分支时触发构建?
1 回答
1
我可能落入了同样的陷阱:我为 Gitea 配置了一个 webhook,指向https://jenkins/job/myJob/build?token=abcdef...
它在任何情况下都可以启动工作。
正确的方法似乎指向 git notifyCommit URL:https://jenkins/git/notifyCommit?url=git@code.example.org:ltorvalds/kernel.git
并使用 SCM 轮询功能:
- 在 Jenkins 上,在
job/myJob/configure
> Build Triggers处,取消选中Trigger builds remote并选中Poll SCM,将计划留空。 - 还要确保
refs/heads/master
在Source Code Management > Git > Branches to build中指定您的分支(例如:) 。
如果 Jenkins 作业是私有的,您可以像这样在 webhook URL 中添加用户名/令牌:https://username:ApiToken@jenkins/git/notifyCommit?url=git@code.example.org:ltorvalds/kernel.git
。见https://wiki.jenkins.io/display/JENKINS/Remote+access+API
于 2019-03-25T17:45:17.097 回答