git - Jenkins 在通过分支索引删除分支时删除作业

标签 git jenkins jenkins-2

有没有办法告诉 Jenkins (2.2) 删除已删除分支的作业?目前我的构建监视器充满了分支,因为作业没有被删除。是否有触发此行为的设置,或者是否应将其作为错误提交?

最佳答案

由于您使用的是最新的 Jenkins 版本,请考虑将您的工作切换到 multibranch pipeline setup

The Workflow Multibranch feature (provided by the workflow plugin) provides the following key abilities:

  • Automatic Workflow (job) creation in Jenkins per new branch in the repo (assuming webhooks are registered from GH to Jenkins).

  • Build specific to that child-branch and its unique scm change and build history.

  • Automatic job pruning/deletion for branches deleted from the repository, according to the settings.

  • Flexibility to individually configure branch properties, by overriding the parent properties, if required.

编辑:检查管道的“丢弃旧项目”设置。如果您有非零的“旧项目的最大数量”,那么如果您的分支机构的构建数量少于这个数字,它将永远不会被删除!您甚至可以在日志中看到:

Will not remove US12345 as it is only #1 in the list
Will not remove US23456 as it is only #2 in the list
Will not remove US34567 as it is only #3 in the list

编辑:您还可以通过添加名为“Prune stale remote-tracking branches”(“行为”->“添加”->从下 pull 列表中选择)的额外行为来试试运气。

关于git - Jenkins 在通过分支索引删除分支时删除作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37210799/

相关文章:

ruby - Chef Recipe 错误 : Error Resolving Cookbooks for Run List

continuous-integration - 在jenkins构建结果页面中显示工件

Jenkins 2 多分支管道 - 如何使用角色策略插件限制分支的可见性/执行?

Jenkins 2 Pipelines - 如何为持续交付管道建模

jenkins - 访问 Jenkins 管道中的工作区

python - 添加相互依赖的 python 模块作为 git 子模块

git - 简单快速的 Git rebase /重写

java - GitHub w/BlueJ,我可以 checkout 项目但不能提交更新(或任何项目)

windows - Jenkins 错误克隆远程 repo 'origin',从节点

Jenkins:groovy DSL:使用三元运算符来区分 FreeStyleJob 和 MatrixJob