Jenkins git提交特定的分支触发器也为其他分支构建作业

Sid*_*h B 6 git github jenkins

我们有一个内部企业Github repo,我有多个功能分支.我正面临着触发特定分支上的构建的问题.我为每个功能分支配置了作业.一个功能分支有一个jenkins工作.我第一次提交代码时,它还触发了与其他分支的作业的构建.

重现问题的步骤:

1.我们有一个企业内部Github.对于我的回购,我已经为github设置了webhook,如下所示

 Settings -> Webhooks & Services -> Services
 Select Jenkins (GitHub plugin) 
 Jenkins Hook Url: http://************/jenkins/github-webhook/
Run Code Online (Sandbox Code Playgroud)

2.对于github repo中的3个分支:branch1,branch2,branch3,我在jenkins中创建了三个作业:Job1,Job2,Job3,SCM配置如下

Source Code Management:
Repo URL: git@********/********.git
Branches to Build: refs/heads/BRANCH_NAME

Build Trigger: Build when a change is pushed to GitHub
Run Code Online (Sandbox Code Playgroud)

3.将代码提交给我的分支:branch1.它会触发jenkins中的所有3个作业:Job1,Job2,Job3.注意:这是第一次触发作业.

4.On代码第二次提交分支:branch1.它只触发jenkins中的Job1.

看起来第一次所有工作都要为回购执行,无论分支如何.

关于我的jenkins设置的详细信息:Jenkins版本:1.565.1,GitHub插件:1.9.1

任何有助于解决此问题的帮助/指导都表示赞赏.

仅供参考:我尝试过上面列出的步骤http://kohsuke.org/2011/12/01/polling-must-die-triggering-jenkins-builds-from-a-git-hook/

Joa*_*ino 0

使用以下命令创建一个脚本(假设你的github SO是linux)

curl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository>
Run Code Online (Sandbox Code Playgroud)

将此脚本放入 ./git/hooks

在你的詹金斯工作变动

来自 “将更改推送到 GitHub 时构建”

前往“投票 SCM”

不要在 Poll SCM 中创建任何计划