如何从 Jenkins 中的构建中排除 git branch [英] How to exclude git branch from building in Jenkins

查看:41
本文介绍了如何从 Jenkins 中的构建中排除 git branch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我当前为一个项目设置的 Jenkins:

Here is my current Jenkins setup for a project:

  • 一个作业运行所有开发分支
  • 一个作业运行所有拉取请求
  • 一个作业只运行 master 分支
  • 只有当master通过时,一项工作才会自动发布

此设置使我能够在开发过程中持续进行自动化交付以及持续反馈.前 3 个作业还运行所有测试和覆盖率报告.

This setup allows me to have continuous automated delivery as well as constant feedback during development. The first 3 jobs also run all tests and coverage reports.

问题是我找不到从所有开发分支"作业中排除主分支的方法.每次我合并一个拉取请求时,它都会不必要地构建两次 master.

The problem is that I could not find a way to exclude the master branch from the "all development branches" job. It unnecessarily builds master twice every time I merge a pull-request.

有人知道如何从 Jenkins 的工作中排除一个分支吗?

Does anybody know how to exclude one branch from the job in Jenkins ?

ps:我正在使用 Git 和 Github 插件.我的项目存储在 Github 上.

ps: I am using the Git and the Github plugins. My project is stored on Github.

推荐答案

您可以选择反向"策略来定位要构建的分支.

You can choose "Inverse" strategy for targeting branches to build.

查看 Jenkins 作业配置,

Check out Jenkins job configuration,

  • 源代码管理"部分(选择Git")
  • 其他行为
  • 点击添加"按钮
  • 选择选择构建内容的策略"
  • 在组合框中选择反向"策略.

(不要忘记用master"填写Branches to build"文本字段)

(Don't forget to fill in "Branches to build" text field by "master")

另见附件截图:

这篇关于如何从 Jenkins 中的构建中排除 git branch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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