Reputation: 1370
I am using Jenkins with Throttle Concurrent Builds plugin and trying to add Throttle Category in jenkins configuration(Jenkins=>manage Jenkins=> Configure System=>Throttle Concurrent Builds). Is it possible to configure it using groovy? Thanks.
Upvotes: 1
Views: 1042
Reputation: 1370
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()
Upvotes: 3