Jenkins windows node 上无法执行 system groovy script
想在jenkins windows 节点执行 Jenkins master 环境下的 groovy脚本:
jenkins version : Jenkins 2.289.1
import hudson.FilePath
import jenkins.model.*
node_workpace=build.moduleRoot.toString()
node_channel=build.workspace.channel
try{
def cppatchfile = new FilePath(node_channel, node_workpace+"/pr_descriptions.txt")
aString = cppatchfile.readToString()
}catch(java.nio.file.NoSuchFileException e){
println("cppatchset.txt do not exist,build stop.")
build.doStop()
}
String hString = null
StringBuffer sBuffer = new StringBuffer();
for(String itemString : aString.split("\n")) {
String pr_number = itemString.split(" ")[1];
String repo_name = itemString.split(" ")[0];
String urlString = String.format("https://bitbucket.huawei.com/projects/HW/repos/%s/pull-requests/%s/overview", repo_name,pr_number);
String htmlString = String.format("<a href=%s>%s</a> ", urlString,pr_number.toString());
println "url: "+urlString
println "item: "+itemString.toString()
sBuffer.append(htmlString);
hString= sBuffer.toString();
}
build.description=hString// Set child build description

结果发现build step 里面没有这个步骤. 可是在另一个JOB 里面是有这个步骤的.
最终发现,当JOB执行节点 是 windows节点的时候就没有这个step, 但是当执行节点是linux节点的时候可以看到这个step.
我先将节点选为 linux,进行配置后,改回节点为windows. 执行成功.
浙公网安备 33010602011771号