提交 ef4d1553 编写于 作者: J Jesse Glick

[JENKINS-27178] Amended merge of #1590.

(cherry picked from commit 87ab95e7)
上级 121f3bce
......@@ -63,6 +63,9 @@ Upcoming changes</a>
<div id="rc" style="display:none;"><!--=BEGIN=-->
<h3><a name=v1.601>What's new in 1.601</a> <!--=DATE=--></h3>
<ul class=image>
<li class="major bug">
Regression with environment variables in 1.600.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-27188">issue 27188</a>)
<li class=bug>
Errors in Dashboard View plugin since 1.597.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-26690">issue 26690</a>)
......
......@@ -942,18 +942,18 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
* Gets the environment variables of the JVM on this computer.
* Returns cached environment variables (copy to prevent modification) for the JVM on this computer.
* If this is the master, it returns the system property of the master computer.
*/
public EnvVars getEnvironment() throws IOException, InterruptedException {
EnvVars cachedEnvironment = this.cachedEnvironment;
if (cachedEnvironment != null) {
return cachedEnvironment;
return new EnvVars(cachedEnvironment);
}
cachedEnvironment = EnvVars.getRemote(getChannel());
this.cachedEnvironment = cachedEnvironment;
return cachedEnvironment;
return new EnvVars(cachedEnvironment);
}
/**
......
......@@ -23,6 +23,7 @@
*/
package hudson.model;
import hudson.EnvVars;
import hudson.FilePath;
import hudson.model.Node.Mode;
import hudson.model.Queue.WaitingItem;
......@@ -52,6 +53,7 @@ import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.MockQueueItemAuthenticator;
import org.jvnet.hudson.test.TestExtension;
......@@ -238,6 +240,19 @@ public class NodeTest {
assertNotNull("Slave which is added into Jenkins list nodes should have assigned computer.", slave.toComputer());
}
@Issue("JENKINS-27188")
@Test public void envPropertiesImmutable() throws Exception {
Slave slave = j.createSlave();
String propertyKey = "JENKINS-27188";
EnvVars envVars = slave.getComputer().getEnvironment();
envVars.put(propertyKey, "huuhaa");
assertTrue(envVars.containsKey(propertyKey));
assertFalse(slave.getComputer().getEnvironment().containsKey(propertyKey));
assertNotSame(slave.getComputer().getEnvironment(), slave.getComputer().getEnvironment());
}
@TestExtension
public static class LabelFinderImpl extends LabelFinder{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册