@Override
public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException {
EnvVars envs = super.getEnvironment(log);
for (EnvironmentContributingAction a : Util.filter(getProject().getActions(), EnvironmentContributingAction.class)) {
try {
try {
EnvironmentContributingAction.class.getMethod("buildEnvironment", Run.class, EnvVars.class).invoke(a, this, envs);
} catch (NoSuchMethodException x) {
EnvironmentContributingAction.class.getMethod("buildEnvVars", AbstractBuild.class, EnvVars.class).invoke(a, this, envs);
}
} catch (Exception x) {
LOGGER.log(Level.WARNING, null, x);
}
}
String opts = getMavenOpts(log,envs);
if(opts!=null)
envs.put("MAVEN_OPTS", opts);
return envs;
}