I am trying to trigger my email promotion job from my pipeline which extracts the repo name from Jenkins
messages. But not able to resolve the SerializableException
error for this block. Any help is greatly appreciated.
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]]
}
}
}
Below is the error messages i am receiving :
[Pipeline] // script Error when executing success post condition:
java.io.NotSerializableException: java.util.regex.Matcher at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926) at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65) at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56) at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50) at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
You need to release manager
immediately after using. More detail can find in this 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]
]
}