开始詹金斯并行构建?

start jenkins builds parallely?

我有 'n' 没有。工作,我想同时开始。在詹金斯可行吗?我尝试使用 DSL 插件、工作流插件。我使用了 'parallel' 方法。我在 array/list 中有我的工作名称列表,并希望 运行 它们并行。请帮忙。

目前我正在迭代数组中的作业名称,因此它们一个接一个地开始,而不是我希望它们并行开始。如何实现?

我以前做过。我发现对我有用的解决方案是通过使用 upstream/downstream 作业,使用 Build Pipeline Plugin.

可视化

本质上,创建一个空白 'bootstrap' 作业,用于启动并行 运行 所需的所有作业,每个并行作业都具有 bootstrap作为上游触发器的作业。

我们一直用来并行触发多个作业的选项是 https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin 然后我们有一个主作业,它只需要一个逗号分隔的所有要调用作业的列表。

在我看来,最好的方法(它会提高你的个人技能;-))是使用 Jenkins Pipeline !!

您可以在下面找到一个简单的代码示例

// While you can't use Groovy's .collect or similar methods currently, you can
// still transform a list into a set of actual build steps to be executed in
// parallel.

// Our initial list of strings we want to echo in parallel
def stringsToEcho = ["a", "b", "c", "d"]

// The map we'll store the parallel steps in before executing them.
def stepsForParallel = [:]

// The standard 'for (String s: stringsToEcho)' syntax also doesn't work, so we
// need to use old school 'for (int i = 0...)' style for loops.
for (int i = 0; i < stringsToEcho.size(); i++) {
    // Get the actual string here.
    def s = stringsToEcho.get(i)

    // Transform that into a step and add the step to the map as the value, with
    // a name for the parallel step as the key. Here, we'll just use something
    // like "echoing (string)"
    def stepName = "echoing ${s}"

    stepsForParallel[stepName] = transformIntoStep(s)
}

// Actually run the steps in parallel - parallel takes a map as an argument,
// hence the above.
parallel stepsForParallel

// Take the string and echo it.
def transformIntoStep(inputString) {
    // We need to wrap what we return in a Groovy closure, or else it's invoked
    // when this method is called, not when we pass it to parallel.
    // To do this, you need to wrap the code below in { }, and either return
    // that explicitly, or use { -> } syntax.
    return {
        node {
            echo inputString
        }
    }
}  

这将满足您的要求

    GParsPool.withPool(NO.OF.THREADS){
        sampleList.eachParallel{
            callYourMethod(it)
        }
    }