2012-04-17 39 views
0

由於Jenkins 1.460,在MavenBuild的實例上調用getMavenArtifacts()正在返回null,而之前的工作正常。Jenkins - MavenBuild.getMavenArtifacts()返回NULL

Jenkins API中是否發生過突變,或者這是一個Jenkins錯誤?

我執行的代碼生成後,系統Groovy腳本,暴露構建的Maven的版本,如在詹金斯後續步驟的環境變量構建過程中使用:

import hudson.model.*; 
import hudson.util.*; 

def thr = Thread.currentThread(); 
def currentBuild = thr?.executable; 
def mavenVer = currentBuild.getMavenArtifacts().getModuleRecords()[0].mainArtifact.version; 
def newParamAction = new hudson.model.ParametersAction(new hudson.model.StringParameterValue("MAVEN_VERSION", mavenVer)); 
currentBuild.addAction(newParamAction); 
+0

肯定有過[更改Maven插件(https://github.com/jenkinsci/jenkins/commits/jenkins-1.460/maven - 插件)爲1.460。如果將Jenkins滾回到以前的版本不是一種選擇,請考慮將插件固定到以前的版本。 – 2012-04-18 08:13:30

回答

1

我找到了一種解決方法,儘管我不知道爲什麼要對API進行未經宣佈的重大更改 - 希望這是一個可以修復的錯誤。

替補:

def mavenVer = currentBuild.getMavenArtifacts().getModuleRecords()[0].mainArtifact.version; 

def mavenVer = currentBuild.getParent().getModules().toArray()[0].getVersion(); 
+0

嘿我得到這個異常,我在詹金斯1.625.3.2 =>錯誤:生成步驟失敗,例外 groovy.lang.MissingMethodException:沒有方法的簽名:hudson.model.FreeStyleProject.getModules()適用參數類型:()values:[] 可能的解決方案:getModuleRoot(),getModuleRoots(),getBuilds(),getWidgets() – Max 2016-03-09 18:17:56