|
46 | 46 | import java.util.ArrayList;
|
47 | 47 | import java.util.Arrays;
|
48 | 48 | import java.util.Collection;
|
| 49 | +import java.util.Iterator; |
49 | 50 | import java.util.List;
|
50 | 51 | import java.util.Map;
|
51 | 52 | import java.util.LinkedHashMap;
|
@@ -126,7 +127,11 @@ public static class Execution extends AbstractStepExecutionImpl {
|
126 | 127 | EnvVars envReduced = new EnvVars(env);
|
127 | 128 | EnvVars envHost = computer.getEnvironment();
|
128 | 129 | envReduced.entrySet().removeAll(envHost.entrySet());
|
| 130 | + |
| 131 | + // Remove PATH during cat. |
| 132 | + envReduced.remove("PATH"); |
129 | 133 | envReduced.remove("");
|
| 134 | + |
130 | 135 | LOGGER.log(Level.FINE, "reduced environment: {0}", envReduced);
|
131 | 136 | workspace.mkdirs(); // otherwise it may be owned by root when created for -v
|
132 | 137 | String ws = workspace.getRemote();
|
@@ -236,7 +241,17 @@ private static class Decorator extends LauncherDecorator implements Serializable
|
236 | 241 | } // otherwise we are loading an old serialized Decorator
|
237 | 242 | Set<String> envReduced = new TreeSet<String>(Arrays.asList(starter.envs()));
|
238 | 243 | envReduced.removeAll(Arrays.asList(envHost));
|
| 244 | + |
| 245 | + // Remove PATH during `exec` as well. |
| 246 | + Iterator<String> it = envReduced.iterator(); |
| 247 | + while (it.hasNext()) { |
| 248 | + if (it.next().startsWith("PATH=")) { |
| 249 | + it.remove(); |
| 250 | + } |
| 251 | + } |
| 252 | + LOGGER.log(Level.FINE, "(exec) reduced environment: {0}", envReduced); |
239 | 253 | prefix.addAll(envReduced);
|
| 254 | + |
240 | 255 | // Adapted from decorateByPrefix:
|
241 | 256 | starter.cmds().addAll(0, prefix);
|
242 | 257 | if (starter.masks() != null) {
|
|
0 commit comments