[JIRA] (JENKINS-40274) java.io.NotSerializableException: hudson.model.FreeStyleBuild

2018-02-23 Thread andrew.ba...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Andrew Bayer resolved as Not A Defect  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 This is happening because you're defining lastBuild and lastBuildResult without def, so they're scoped globally to the entire Pipeline script. And then when the Pipeline gets serialized, as happens with every step execution so that it can be resumed after a master restart, those variables are in the global scope and Pipeline attempts to serialize them. So...yeah. Be more careful about scopes. Also, we'd advise strongly against using Jenkins APIs in your Pipeline. That's not guaranteed to keep working.  
 

  
 
 
 
 

 
 Jenkins /  JENKINS-40274  
 
 
  java.io.NotSerializableException: hudson.model.FreeStyleBuild   
 

  
 
 
 
 

 
Change By: 
 Andrew Bayer  
 
 
Status: 
 Open Resolved  
 
 
Resolution: 
 Not A Defect  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)  
 
 

 
   
 
   

[JIRA] (JENKINS-40274) java.io.NotSerializableException: hudson.model.FreeStyleBuild

2016-12-07 Thread hanbingxi...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 jubel han created an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-40274  
 
 
  java.io.NotSerializableException: hudson.model.FreeStyleBuild   
 

  
 
 
 
 

 
Issue Type: 
  Bug  
 
 
Assignee: 
 Unassigned  
 
 
Components: 
 pipeline  
 
 
Created: 
 2016/Dec/07 9:23 AM  
 
 
Environment: 
 Jenkins 2.28  pipeline-job plugin 2.8  ubuntu 14.04  chrome 54.0.2840.98  firefox 50.0  
 
 
Labels: 
 pipeline  
 
 
Priority: 
  Major  
 
 
Reporter: 
 jubel han  
 

  
 
 
 
 

 
 Here is the pipeline groovy code for tested. 

 

import jenkins.model.*

@NonCPS
def getJobStatus(def jobName) {
def job = Jenkins.instance.getJob(jobName)
lastBuild = job.getLastCompletedBuild()
lastBuildResult = lastBuild.getResult().toString()
return lastBuildResult;
}
node {
stage "Get Job Status"
result = getJobStatus("example_job")
print result
}
 

 Here is the failed console output: 

 

ava.io.NotSerializableException: hudson.model.FreeStyleBuild
	at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
	at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
	at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller