当使用 Groovy Jenkins 插件(不是 Groovy Post Build Plugin,这是另一回事)作为 Post Step 时,我无法解析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;
[...]