variable is not correct get in jenkins docker.inside()

36 views Asked by At

In docker plugin parallel situation, the x didn't get correct output in docker.image.inside, and always get the last element in the array, is there any solution? Here is the example code,

node {
x_array = [1,2]
x_map = [:]
image = "centos:latest"
    for (x in x_array) {
        x_map[x] = {
        image = docker.image(image)
        image.pull
        image.inside("-t") {
             sh "echo $x"
        }
        }
    }
    parallel x_map
}

Here is the output: 2 2 While expect output: 1 2

0

There are 0 answers