Jenkins共享管道存在此问题。尝试使用脚本标签,但仍然遇到相同的错误。作业运行正常,但在日志中添加了堆栈跟踪
def call(def suite = "*") {
cucumber jsonReportDirectory: env.Q3_DIR, parallelTesting: true, fileIncludePattern: "**/${suite}.json", sortingMethod: 'ALPHABETICAL'
List<String> logPaths = findFiles(glob: "**/q3.log")
if (!logPaths.empty && logPaths != null) {
log.debug("log: ${logPaths.first().path}")
if(suite != "*")
sh "mv ${logPaths.first().path} ${suite}_q3.log"
archiveArtifacts "**/*q3.log"
}
echo "Pipeline running on node: ${env.NODE_NAME}"
def currentNode =jenkins.model.Jenkins.instance.getNode(env.NODE_NAME)
/* change node lable before restore job as invoking job is asyncronous */
echo "Changing label for Node ${currentNode.getNodeName()}"
String oldLabel = currentNode.getLabelString();
echo "Old label is ${oldLabel}"
script {
currentNode.setLabelString("BeingRestored")
currentNode.save()
echo "Changed label to 'BeingRestored'"
echo "Preparing to cleanup node: ${env.NODE_NAME}"
//build job: "Restore-${env.NODE_NAME}", wait: false
build job: 'Restore-VM-Node', parameters: [[$class: 'StringParameterValue', name: 'REQUESTED_ACTION', value: 'restore'],
[$class: 'StringParameterValue', name: 'NODE_LABEL', value: "${env.NODE_NAME}"],
[$class: 'StringParameterValue', name: 'LABEL_NAME', value: "${currentNode.getNodeName()}"]]
}
}
错误详细信息
DEBUG: log: q3.log
[Pipeline] step
Archiving artifacts
[Pipeline] echo
Pipeline running on node: server-vm2
[Pipeline] echo
Changing label for Node server-vm2
[Pipeline] echo
Changed label to 'BeingRestored'
[Pipeline] echo
Preparing to cleanup node: server-vm2
[Pipeline] build (Building Restore-VM-Node)
Error when executing always post condition:
java.io.NotSerializableException: hudson.plugins.sshslaves.SSHLauncher
at
.....
Scheduling project: Restore-VM-Node
我无法找出上述代码的问题。
答案 0 :(得分:0)
问题在于TreeMap,构建作业参数作为TreeMap与不可序列化的比较器一起传递。下面的代码更改工作正常
build job: 'Restore-VM-Node', parameters: [
string( name: 'REQUESTED_ACTION', value: 'restore'),
string(name: 'NODE_LABEL', value: "${env.NODE_NAME}"),
string(name: 'LABEL_NAME', value: "${oldLabel}")
], wait:false