提交 e04da4a2 编写于 作者: D Daniel Beck 提交者: Oliver Gondža

[FIX JENKINS-40894] Restore unstableReturn in readResolve

(cherry picked from commit 93467c3f)
上级 ea97d511
......@@ -81,7 +81,9 @@ public class BatchFile extends CommandInterpreter {
}
private Object readResolve() throws ObjectStreamException {
return new BatchFile(command);
BatchFile batch = new BatchFile(command);
batch.setUnstableReturn(unstableReturn);
return batch;
}
@Extension @Symbol("batchFile")
......
......@@ -125,7 +125,9 @@ public class Shell extends CommandInterpreter {
}
private Object readResolve() throws ObjectStreamException {
return new Shell(command);
Shell shell = new Shell(command);
shell.setUnstableReturn(unstableReturn);
return shell;
}
@Extension @Symbol("shell")
......
package hudson.tasks;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assume.assumeTrue;
......@@ -16,6 +17,7 @@ import hudson.Launcher.ProcStarter;
import hudson.Proc;
import hudson.model.Result;
import hudson.model.FreeStyleProject;
import org.jvnet.hudson.test.recipes.LocalData;
/**
......@@ -148,4 +150,13 @@ public class BatchFileTest {
/* Creating unstable=0 produces unstable=null */
assertNull( createNewBatchTask("",0).getUnstableReturn() );
}
@Issue("JENKINS-40894")
@Test
@LocalData
public void canLoadUnstableReturnFromDisk() throws Exception {
FreeStyleProject p = (FreeStyleProject) rule.jenkins.getItemByFullName("batch");
BatchFile batchFile = (BatchFile) p.getBuildersList().get(0);
assertEquals("unstable return", Integer.valueOf(1), batchFile.getUnstableReturn());
}
}
......@@ -27,6 +27,7 @@ import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.recipes.LocalData;
/**
* Tests for the Shell tasks class
......@@ -190,4 +191,13 @@ public class ShellTest {
assertNull( createNewShell("",0).getUnstableReturn() );
}
@Issue("JENKINS-40894")
@Test
@LocalData
public void canLoadUnstableReturnFromDisk() throws Exception {
FreeStyleProject p = (FreeStyleProject) rule.jenkins.getItemByFullName("test");
Shell shell = (Shell) p.getBuildersList().get(0);
assertEquals("unstable return", Integer.valueOf(1), shell.getUnstableReturn());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册