我使用 Jenkins 的视图功能对我的工作进行分组。但我不确定我是否失去了工作。 是否可以找到不属于任何视图的工作? 或者是否可以找到属于 2 个视图的任何工作?
为了避免这种混乱,我使用正则表达式来分配要查看的作业以及作业的命名约定。其他一切都会碰运气。
此外,如果您没有该作业的权限,该作业将不会显示在视图中。
我使用这个常规脚本来列出没有任何关联视图的作业
Set<String> projects = new HashSet<>();
final List<TopLevelItem> items = Jenkins.get().getItems();
for (Item item : items) {
projects.add(item.getFullName());
}
Set<String> projectsWithView = new HashSet<>();
final Collection<View> views = Jenkins.get().getViews();
for (View view : views) {
if (!(view instanceof AllView)){
final Collection<TopLevelItem> allItems = view.getAllItems();
for (TopLevelItem allItem : allItems) {
projectsWithView.add(allItem.getFullName());
}
}
}
println(projects.size());
projects.removeAll(projectsWithView);
println(projects.size());
println(projects);