Skip to content
Permalink
Browse files

[JENKINS-36237] - Improve diagnostics of issues in EnvInjectBuildWrap…

…per (#105)

Now EnvInjectBuildWrapper#setUp() provides more info in the build log and also forwards stacktrace to the system log.
In addition, we rethrow Errors since we cannot recover from them
  • Loading branch information
oleg-nenashev committed Sep 26, 2016
1 parent e58e0c4 commit a8989123b6fa9f036a70998894b4f626aee02856
Showing with 11 additions and 2 deletions.
  1. +11 −2 src/main/java/org/jenkinsci/plugins/envinject/EnvInjectBuildWrapper.java
@@ -18,6 +18,8 @@
import hudson.scm.SCM;
import hudson.tasks.BuildWrapper;
import hudson.tasks.BuildWrapperDescriptor;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nonnull;
import net.sf.json.JSONObject;

@@ -35,7 +37,9 @@

@Nonnull
private EnvInjectJobPropertyInfo info;


private static final Logger LOGGER = Logger.getLogger(EnvInjectBuildWrapper.class.getName());

@DataBoundConstructor
public EnvInjectBuildWrapper(@Nonnull EnvInjectJobPropertyInfo info) {
this.info = info;
@@ -120,8 +124,13 @@ public void buildEnvVars(Map<String, String> env) {
}
};
} catch (Throwable throwable) {
logger.error("Problems occurs on injecting env vars as a build wrap: " + throwable.getMessage());
logger.error("Problems occurs on injecting env vars defined in the build wrapper: " + throwable + ". See system log for more info");
LOGGER.log(Level.WARNING, String.format("Problems occurs on injecting env vars defined in the build wrapper for build {0}", build), throwable);
build.setResult(Result.FAILURE);
if (throwable instanceof Error) {
// Errors must be always propagated since we cannot recover from them
throw (Error)throwable;
}
return null;
}
}

0 comments on commit a898912

Please sign in to comment.
You can’t perform that action at this time.