It does not have the same introspection as Jenkins parallel step, but since it does not support a fixed pool, you can use xargs to achieve the same result:
def files = findFiles glob: 'test_files/*' def branches = [:] // there probably a more efficient way to generate the list of commands files.each{ sh "echo './test ${it}' >> tests.txt" } sh 'cat tests.txt | xargs -L 1 -I {} -P 2 bash -c "{}"'
The -P argument is one that indicates that a fixed number of 2 (or N) processes should always be executed. Other tools, such as GNU Parallel, offer even greater customization of how many processes should be used.
You can also try using the lock step from the Lockable Resources plugin , a node step oriented to a fixed number of executors. However, for me this is too much overhead if your single tests already take tens of seconds each.
source share