仅在特定分支发生更改时才触发Jenkins Job [英] Trigger Jenkins Job only when changes happen to a particular branch

查看:105
本文介绍了仅在特定分支发生更改时才触发Jenkins Job的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经配置了jenkins作业,希望当我对该特定分支的Github进行一些更改时,应该触发该作业.

I have configured a jenkins job and I wish it should be triggered when I make some changes to the Github for that particular branch.

我使用Github插件并启用了将更改推送到github时构建".
但是,如果其他人创建了一个单独的分支并将其推送到该分支,则此选项将触发我的工作.

I use the Github plugin and has enabled "build when a change is pushed to github".
But this option is triggering my Job if someone else create a separate branch and push to that branch.

下面让我解释一下:

Change pushed to branch "release"
Jenkins notified and job executes - Expected behavior
Another change is now pushed to branch "xyz" but I don't intend this to cause execution of my Jenkins job. The Job "xyz" is created out of the same repo though.

如何防止推送到其他分支的更改触发我的工作?

How can I prevent changes pushed to other branches triggering my job?

启用将更改推送到github时构建"是不正确的吗?

Is enabling "build when a change is pushed to github" is not correct?

推荐答案

在作业配置的git部分中,有一个字段"Branches to build".您可以在此处指定将新的提交推送到它们时哪些分支将触发构建.

In the git section of the job configuration is a field 'Branches to build'. You can specify here which branches will trigger a build when new commits are pushed to them.

例如对于我的一项工作,我拥有**/BARE- *,因此只有以BARE-开头的分支才会触发构建.

e.g. for one of my jobs I have **/BARE-* , so only branches which start with BARE- will trigger a build.

这篇关于仅在特定分支发生更改时才触发Jenkins Job的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆