2014-02-28 24 views
0

我通過jenkins-job-dsl v1.20在那裏我有以下行試圖建立幾個工作:構建步驟mavenInstallation在通過詹金斯在職DSL創造就業

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) 

      } 
     } 
    } 
} 

的問題是,我的工作會通過適當的步驟生成,但maven安裝始終是「默認」。 Jenkins中的下拉框可以用上面的值選擇,並且適當的Maven版本被安裝並可用。

因此,無論我在一個常規問題上是否存在缺陷,或者我誤解了其他事情?任何想法?

回答

0

嗯,我最初認爲你需要將mavenInstallation(it)更改爲mavenInstallation($ {it}),但由於某些原因,這並不起作用。但是,下面的工作。可能來不及發佈您的問題

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) 
     } 
    } 
} 
}