*/
public static EnvVars getPollEnvironment(AbstractProject p, FilePath ws, Launcher launcher, TaskListener listener)
throws IOException, InterruptedException {
EnvVars env;
AbstractBuild b = (AbstractBuild) p.getLastBuild();
if (b != null) {
Node lastBuiltOn = b.getBuiltOn();
if (lastBuiltOn != null) {
env = lastBuiltOn.toComputer().getEnvironment().overrideAll(b.getCharacteristicEnvVars());
} else {
env = new EnvVars(System.getenv());
}
String rootUrl = Hudson.getInstance().getRootUrl();
if (rootUrl != null) {
env.put("HUDSON_URL", rootUrl);
env.put("BUILD_URL", rootUrl + b.getUrl());
env.put("JOB_URL", rootUrl + p.getUrl());
}
if (!env.containsKey("HUDSON_HOME")) {
env.put("HUDSON_HOME", Hudson.getInstance().getRootDir().getPath());