我试图从我的管道中触发我的电子邮件推广工作,该管道从Jenkins
消息中提取回购名称。但是无法解决此块的SerializableException
错误。任何帮助将不胜感激。
post{
success{
script{
@NonCPS
//upstream_job_name = null
def manager = manager.getLogMatcher('.*Obtained Jenkinsfile from git (.*)$')
if(manager.matches()){
def gitMsg=manager.group(1)
gitrepo = "${gitMsg}"
echo gitrepo
def upstream_job_name = gitrepo.split("/")[4].replace(".git", "")
println upstream_job_name
}
build job: 'job-approval' , parameters: [[$class: 'StringParameterValue', name: 'upstream_job_name', value: upstream_job_name]]
}
}
}
以下是我收到的错误消息:
[管道] //脚本 执行成功发布条件时出错:
java.io.NotSerializableException:java.util.regex.Matcher 在org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926) 在org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65) 在org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56) 在org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50) 在org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
答案 0 :(得分:0)
使用后,您需要立即释放manager
。可以在此post
script{
//upstream_job_name = null
def manager = manager.getLogMatcher('.*Obtained Jenkinsfile from git (.*)$')
if(manager.matches()){
def gitMsg=manager.group(1)
gitrepo = "${gitMsg}"
echo gitrepo
def upstream_job_name = gitrepo.split("/")[4].replace(".git", "")
println upstream_job_name
}
manager = null
build job: 'job-approval' ,
parameters: [
[$class: 'StringParameterValue', name: 'upstream_job_name', value: upstream_job_name]
]
}