问题
is it possible to manage some resources in Jenkins? By that I mean only certain number of jobs should run in parallel. E.g. my license server can provide only 4 licenses, so each job that uses such license should first check if some counter is greater that zero, next decrement and increment back after license is not needed anymore. There is Exclusion Plugin, but I think it can only create mutex (counter equals 1) not semaphore (counter equals 1 or more). Simple variable in script is not a solution, because same counter must be visible by master and all slaves. Any ideas how to handle that? Thanks in advance.
回答1:
You can use the Throttle Concurrent Builds Plugins. You can do it in two ways:
- If the restriction applies to only one job, you can edit the job itself. There is a Throttle Concurrent Builds setting, where you can configure how many concurrent builds of the same job are allowed.
- If there are multiple jobs that have to be restricted, then you can define Multi-Project Throttle Categories in the global configuration. You define a category with a restriction, and then tag every job that has to be restricted with this category.
来源:https://stackoverflow.com/questions/10845889/jenkins-resource-management