0

I'm trying to setup a couple of jobs via jenkins-job-dsl v1.20 where i have the following lines:

def existingMavenInstallations = [ "Maven 2.0.11", "Maven 2.2.1", "Maven 3.0.5", "Maven 3.1.0", "Maven 3.1.1" ]

job {

    name 'WhatEverName'

    jdk (...)

    steps {
        existingMavenInstallations.each {
          maven {
              mavenInstallation(it)
              goals("-B -Prun-its clean verify")
              localRepository(LocalToWorkspace)

          }
        }
    }
}

The problem is that my jobs will be generated with appropriate steps but the maven installation is always "default". The drop-down-box in Jenkins can be selected with the above values and the appropriate Maven versions are installed and available.

So either i'm stumblig over a groovy problem or i misunderstand an other thing ? Any idea?

khmarbaise
  • 92,914
  • 28
  • 189
  • 235

1 Answers1

0

Well, I initial thought you need to change mavenInstallation(it) to mavenInstallation(${it}) but for some reason that did not work. However following does work. May to too late to post for your issue

def existingMavenInstallations = [ "Maven 2.0.11", "Maven 2.2.1", "Maven 3.0.5", "Maven 3.1.0", "Maven 3.1.1" ]

job {
name 'WhatEverName'

jdk (...)

steps {
    for(int i=0; i < existingMavenInstallations.size(); i++) {
      maven {
          mavenInstallation("${existingMavenInstallations.get(i)}")
          goals("-B -Prun-its clean verify")
          localRepository(LocalToWorkspace)
      }
    }
}
}
Pushkar
  • 541
  • 4
  • 18