我正在使用Jenkins和Throttle Concurrent Builds插件并尝试在jenkins配置中添加Throttle Category(Jenkins => manage Jenkins => Configure System => Throttle Concurrent Builds)。是否可以使用groovy进行配置?感谢。
答案 0 :(得分:2)
String expectedLabel = "testLabel";
Integer expectedMax = new Integer(1);
ThrottleJobProperty.ThrottleCategory category =
new ThrottleJobProperty.ThrottleCategory('testCategoryName3', 0, 0, null);
List<ThrottleJobProperty.NodeLabeledPair> nodeLabeledPairs = category.getNodeLabeledPairs();
nodeLabeledPairs.add(new ThrottleJobProperty.NodeLabeledPair(expectedLabel, expectedMax));
ThrottleJobProperty.DescriptorImpl descriptor = Jenkins.getInstance().getDescriptorByType(ThrottleJobProperty.DescriptorImpl.class)
categories = descriptor.getCategories()
categories.add(category)
descriptor.save()