5
當使用Groovy Jenkins插件(不是Groovy Post Build Plugin,這是另一回事)作爲後續步驟時,我無法解析hudson.model
包中的類。Jenkins Groovy類路徑上的軟件包?
是否需要將Jenkins .war添加到類路徑中,還是應該將這些程序包放在那裏?
腳本:
import hudson.model.*;
import hudson.util.*;
AbstractBuild currentBuild = (AbstractBuild) Thread.currentThread().executable;
def mavenVer = currentBuild.getMavenArtifacts().getModuleRecords()[0].mainArtifact.version;
println mavenVer;
ParametersAction newParamAction = new hudson.model.ParametersAction(new hudson.model.StringParameterValue(「MAVEN_VERSION」, mavenVer));
currentBuild.addAction(newParamAction);
輸出:
[Common] $ /home/tester/tools/Groovy_1.8.3/bin/groovy /home/tester/workspace/Common/hudson8369102960709507246.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/home/tester/workspace/Common/hudson8369102960709507246.groovy: 8: unable to resolve class AbstractBuild
@ line 8, column 15.
AbstractBuild currentBuild = (AbstractBuild) Thread.currentThread().executable;
[...]
當將正確的jar添加到類路徑中時,是否真的有可能以上面的方式運行您的代碼作爲簡單的'Groovy Script'?從Groovy插件文檔中,我得到的印象是,代碼不會像在不同的JVM實例中那樣工作,所以您將無法在已經運行的JVM中添加參數。 – Tonin 2013-05-02 05:51:54
@engineerbetter我知道這是舊的,但要分享如何將這些罐子放在關於Jenkins和Groovy的類路徑中?我只需進入我的Groovy腳本的高級配置,指定我的罐子託管的類路徑? – TekiusFanatikus 2016-02-19 18:38:54