Mihai Dinca
Mihai Dinca

Reputation: 3

Jenkins Declarative Pipeline

I am using Declarative Pipeline in Jenkins and i have more than 200 tests. I want to split them to many machines. i have a piece of code that i have to repair but i dont konw how. The documentation is not so good. Can someone explain me what is happening in these lines of code ?

    def splits = splitTests parallelism: [$class: 'CountDrivenParallelism', size: 3], generateInclusions: true

    def Groups = [:]

    for (int i = 0; i < splits.size(); i++) {

        def split = splits[i]

        Groups["split-${i}"]

Upvotes: 0

Views: 297

Answers (1)

Jacob Aae Mikkelsen
Jacob Aae Mikkelsen

Reputation: 579

The splitTests is a Groovy method that comes from the Parallel Test Executor Plugin for Jenkins. https://wiki.jenkins.io/display/JENKINS/Parallel+Test+Executor+Plugin

In Groovy, you don't have to use parenthesis for method calls, but you can write the same line as this:

def splits = splitTests( parallelism: [$class: 'CountDrivenParallelism', size: 3], generateInclusions: true)

Where the parameters for the method is a Map, with the 3 keys: parallelism, size and generateInclusions.

$Class 'CountDrivenParallelism'

Tells the plugin which implementation for parallelizing the tests should be used.

def Groups = [:]

Defines a new local variable named Groups, and initializes it with a new HashMap. The [:] is short for Map in Groovy.

See fx. this article, that describes the code you have posted: https://jenkins.io/blog/2016/06/16/parallel-test-executor-plugin/ and what it does

Upvotes: 1

Related Questions