@Extension(ordinal = -200)
public class FixEnvVarEnvironmentContributor extends EnvironmentContributor {
@Override
public void buildEnvironmentFor(@SuppressWarnings("rawtypes") @Nonnull Run run, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException {
Computer c = Computer.currentComputer();
if (c != null) {
Field platformField = ReflectionUtils.findField(EnvVars.class, "platform", Platform.class);
ReflectionUtils.makeAccessible(platformField);
Platform currentPlatform = (Platform) ReflectionUtils.getField(platformField, envs);
if (currentPlatform == null) {
EnvVars remoteEnv = c.getEnvironment();
Platform computerPlatform = (Platform) ReflectionUtils.getField(platformField, remoteEnv);
if (computerPlatform != null) {
ReflectionUtils.setField(platformField, envs, computerPlatform);
}
}
}
}
}
This 2012 bug hit again (nodejs plugin).
It break all SimpleBuildWrapper that override PATH+VAR launched on node with different platform (Unix->Windows and vs).
The issue seems to be in Run#getEnvironment(TaskListener) that returns an enviroment EnvVars not built from Computer class (the unique way to have platform field setup correctly)
I think that something similar fix the issue
untill a fix is released my dirty workaround is create a EnvironmentContributor that by reflection inject correct platform value