通过分支索引删除分支时,Jenkins删除作业 [英] Jenkins delete jobs when branch deleted via branch-indexing
问题描述
是否可以告诉Jenkins(2.2)删除已删除分支的作业?目前,由于未删除作业,因此我的构建监视器填充了分支.是否有设置可以触发此行为,还是应该将其记录为错误?
Is there a way to tell Jenkins (2.2) to remove jobs for branches that were deleted? Currently my build-monitor fills up with branches as the jobs are not deleted. Is there a setting to trigger this behavior or should this be filed as a bug?
推荐答案
由于您使用的是最新的Jenkins版本,请考虑将您的工作切换到
Since you are using latest Jenkins version, consider switching your jobs to multibranch pipeline setup.
工作流多分支功能(由工作流插件提供)提供以下关键功能:
The Workflow Multibranch feature (provided by the workflow plugin) provides the following key abilities:
-
在回购中,每个新分支在Jenkins中自动创建工作流(作业)(假设Webhook从GH注册到Jenkins).
Automatic Workflow (job) creation in Jenkins per new branch in the repo (assuming webhooks are registered from GH to Jenkins).
特定于该子分支的构建及其唯一的scm更改和构建历史.
Build specific to that child-branch and its unique scm change and build history.
根据设置自动从存储库中删除分支的作业修剪/删除.
如果需要,可以通过覆盖父属性来灵活地单独配置分支属性.
Flexibility to individually configure branch properties, by overriding the parent properties, if required.
编辑:检查管道的丢弃旧项目"设置.如果您的旧项目的最大数量"非零,那么,如果您的分支的构建数量较少,则此数字将永远不会被删除!您甚至可以在日志中看到它:
EDIT: check the 'Discard Old Items' settings for you pipeline. If you have non-zero 'Max # of old items' then, if your branch had less builds then this number, it will never be deleted! You can even see that in logs:
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
编辑:您还可以通过添加名为修剪陈旧的远程跟踪分支"(行为"->添加"->从下拉列表中选择)的其他行为来尝试自己的运气.
EDIT: You can also try your luck by adding additional behavior named "Prune stale remote-tracking branches" ("Behaviors" -> "Add" -> Select from dropdown).
这篇关于通过分支索引删除分支时,Jenkins删除作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!