如何让Jenkins只有在从bitbucket触发时改变了功能分支 [英] How can I make Jenkins only build feature branches if they have changed when triggering from bitbucket

查看:1937
本文介绍了如何让Jenkins只有在从bitbucket触发时改变了功能分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Jenkins工作,建立与origin / feature /***匹配的分支。

I have a Jenkins job that builds branches that match "origin/feature/**".

Bitbucket触发任务, ( https://confluence.atlassian.com/display/BITBUCKET/) Jenkins + hook + management )。

Bitbucket triggers the job to build whenever there are changes to the repository via a repository hook (https://confluence.atlassian.com/display/BITBUCKET/Jenkins+hook+management).

只要功能分支上有更改,作业就会正常工作,作业识别分支已更改并构建它。

This works fine whenever there is a change on a feature branch, the job recognizes that the branch has changed and builds it.

然而,当有一个提交到非特性分支(例如合并开发或主控)时,bitbucket仍然触发作业。没有对任何功能分支的更改,因此它只是再次构建最后一个构建的功能分支。

However, when there is a commit to a non-feature branch (eg. a merge to develop or master) bitbucket still triggers the job. There are no changes to any of the feature branches so it just builds the last built feature branch again.

有办法控制吗?

推荐答案

研究我最终找到了一个很好的解决方案:

After some research I found a good solution finally:

  • Install Bitbucket Plugin at your Jenkins
  • Add a normal Post as Hook to your Bitbucket repository (Settings -> Hooks) and use following url:

https:// YOUR.JENKINS .SERVER:PORT / bitbucket-hook /

https://YOUR.JENKINS.SERVER:PORT/bitbucket-hook/




  • 按照以下步骤配置Jenkins项目:


    • 构建触发器下启用将更改推送到BitBucket时构建

    • 源代码管理下选择 GIT ;输入您的凭证并定义要构建的分支(如 **功能/ *

      • Configure your Jenkins project as follows:
        • under build trigger enable Build when a change is pushed to BitBucket
        • under Source Code Management select GIT; enter your credentials and define Branches to build (like **feature/*)
        • 通过这种方式,我有三个构建项目,一个用于所有功能,一个用于开发,一个用于发布分支。

          By this way I have three build projects, one for all features, one for develop and one for release branch.

          这篇关于如何让Jenkins只有在从bitbucket触发时改变了功能分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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