Skip to content
Permalink
Browse files

Fix [JENKINS-12252]

  • Loading branch information...
gboissinot committed Jan 1, 2012
1 parent 44643c8 commit c79b61d5c7e79add9a85a5e98665dd67e2ad7812
@@ -61,7 +61,9 @@ public Environment setUp(AbstractBuild build, final Launcher launcher, final Bui
//Execute script info
int resultCode = envInjectEnvVarsService.executeScript(info.getScriptContent(), ws, info.getScriptFilePath(), resultVariables, launcher, listener);
if (resultCode != 0) {
logger.info(String.format("The exit code is '%s'. Fail the build.", resultCode));
logger.info("Fail the build.");
build.setResult(Result.FAILURE);
return null;
}

//Add or get the existing action to add new env vars
@@ -73,7 +75,6 @@ public void buildEnvVars(Map<String, String> env) {
env.putAll(resultVariables);
}
};

} catch (Throwable throwable) {
logger.error("[EnvInject] - [ERROR] - Problems occurs on injecting env vars as a build wrap: " + throwable.getMessage());
build.setResult(Result.FAILURE);
@@ -74,7 +74,8 @@ public Environment setUpEnvironment(AbstractBuild build, Launcher launcher, Buil
info.getScriptContent(),
rootPath, info.getScriptFilePath(), infraEnvVarsMaster, infraEnvVarsNode, propertiesVariables, launcher, listener);
if (resultCode != 0) {
logger.info(String.format("The exit code is '%s'. Fail the build.", resultCode));
build.setResult(Result.FAILURE);
throw new Run.RunnerAbortedException();
}

final Map<String, String> resultVariables = envInjectEnvVarsService.getMergedVariables(infraEnvVarsNode, propertiesVariables);
@@ -91,10 +92,13 @@ public void buildEnvVars(Map<String, String> env) {
}

} catch (EnvInjectException envEx) {
logger.error("SEVERE ERROR occurs: " + envEx.getCause().getMessage());
logger.error("SEVERE ERROR occurs: " + envEx.getMessage());
throw new Run.RunnerAbortedException();
} catch (Run.RunnerAbortedException rre) {
logger.info("Fail the build.");
throw new Run.RunnerAbortedException();
} catch (Throwable throwable) {
logger.error("SEVERE ERROR occurs: " + throwable.getCause().getMessage());
logger.error("SEVERE ERROR occurs: " + throwable.getMessage());
throw new Run.RunnerAbortedException();
}
}
@@ -135,9 +139,10 @@ private boolean isMatrixRun(AbstractBuild build) {


EnvVars envVars = new EnvVars();
for (EnvironmentContributor ec : EnvironmentContributor.all())
for (EnvironmentContributor ec : EnvironmentContributor.all()) {
ec.buildEnvironmentFor(build, envVars, new LogTaskListener(LOG, Level.ALL));
result.putAll(envVars);
result.putAll(envVars);
}

//Global properties
for (NodeProperty<?> nodeProperty : Hudson.getInstance().getGlobalNodeProperties()) {
@@ -59,21 +59,14 @@ public int executeScriptSection(FilePath scriptExecutionRoot,

private int executeScriptPath(FilePath scriptExecutionRoot, String scriptFilePath, Map<String, String> scriptExecutionEnvVars) throws EnvInjectException {
try {
//FilePath f = new FilePath(scriptExecutionRoot, scriptFilePath);
//if (f.exists()) {
launcher.getListener().getLogger().println(String.format("Executing '%s'.", scriptFilePath));
ArgumentListBuilder cmds = new ArgumentListBuilder();
cmds.addTokenized(scriptFilePath);
int cmdCode = launcher.launch().cmds(cmds).stdout(launcher.getListener()).envs(scriptExecutionEnvVars).pwd(scriptExecutionRoot).join();
if (cmdCode != 0) {
logger.info(String.format("The exit code is '%s'. Fail the build.", cmdCode));
logger.info(String.format("The exit code is %s.", cmdCode));
}
return cmdCode;
// } else {
// String message = String.format("Can't load the file '%s'. It doesn't exist.", f.getRemote());
// logger.error(message);
// throw new EnvInjectException(message);
// }
} catch (Throwable e) {
throw new EnvInjectException("Error occurs on execution script file path.", e);
}
@@ -94,7 +87,7 @@ private int executeScriptContent(FilePath scriptExecutionRoot, String scriptCont
logger.info(String.format("Executing and processing the following script content: \n%s\n", scriptContent));
int cmdCode = launcher.launch().cmds(batchRunner.buildCommandLine(tmpFile)).stdout(launcher.getListener()).envs(scriptExecutionEnvVars).pwd(scriptExecutionRoot).join();
if (cmdCode != 0) {
logger.error(String.format("The exit code is '%s'. Fail the build.", cmdCode));
logger.error(String.format("The exit code is %s.", cmdCode));
}
return cmdCode;

0 comments on commit c79b61d

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