Groovy Jenkinsプラグイン(別のものであるGroovy Post Buildプラグインではありません)をポストステップとして使用すると、hudson.model
パッケージ内のクラスを解決できません。
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;
[...]