Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gboissinot committed Aug 1, 2012
1 parent 4d964fa commit 1f0b603
Showing 1 changed file with 38 additions and 35 deletions.
Expand Up @@ -348,50 +348,34 @@ private Map<String, String> getEnvVarsByContribution(AbstractBuild build, EnvInj

@Override
public void onCompleted(Run run, TaskListener listener) {
AbstractBuild build = (AbstractBuild) run;
if (isEligibleJobType(build)) {

if (!(build instanceof MatrixBuild)) {
EnvVars envVars = new EnvVars();
EnvInjectLogger logger = new EnvInjectLogger(listener);
if (!(run instanceof AbstractBuild)) {
return;
}

EnvInjectPluginAction envInjectAction = run.getAction(EnvInjectPluginAction.class);
if (envInjectAction != null) {
AbstractBuild build = (AbstractBuild) run;
if (!isEligibleJobType(build)) {
return;
}

//Remove technical wrappers
try {
BuildWrapperService wrapperService = new BuildWrapperService();
wrapperService.removeBuildWrappers(build, JobSetupEnvironmentWrapper.class);
} catch (EnvInjectException e) {
logger.error("SEVERE ERROR occurs: " + e.getMessage());
throw new Run.RunnerAbortedException();
}
if (!(build instanceof MatrixBuild)) {
EnvVars envVars = new EnvVars();
EnvInjectLogger logger = new EnvInjectLogger(listener);

} else {
//Keep classic injected env vars
AbstractBuild abstractBuild = (AbstractBuild) run;
try {
envVars.putAll(abstractBuild.getEnvironment(listener));
} catch (IOException e) {
logger.error("SEVERE ERROR occurs: " + e.getMessage());
throw new Run.RunnerAbortedException();
} catch (InterruptedException e) {
logger.error("SEVERE ERROR occurs: " + e.getMessage());
throw new Run.RunnerAbortedException();
}
}

//Mask passwords
EnvInjectPasswordsMasker passwordsMasker = new EnvInjectPasswordsMasker();
passwordsMasker.maskPasswordsIfAny(build, logger, envVars);
EnvInjectPluginAction envInjectAction = run.getAction(EnvInjectPluginAction.class);
if (envInjectAction != null) {

//Add or override EnvInject Action
EnvInjectActionSetter envInjectActionSetter = new EnvInjectActionSetter(getNodeRootPath());
//Remove technical wrappers
try {
envInjectActionSetter.addEnvVarsToEnvInjectBuildAction((AbstractBuild<?, ?>) run, envVars);
BuildWrapperService wrapperService = new BuildWrapperService();
wrapperService.removeBuildWrappers(build, JobSetupEnvironmentWrapper.class);
} catch (EnvInjectException e) {
logger.error("SEVERE ERROR occurs: " + e.getMessage());
throw new Run.RunnerAbortedException();
}
} else {
try {
envVars.putAll(build.getEnvironment(listener));
} catch (IOException e) {
logger.error("SEVERE ERROR occurs: " + e.getMessage());
throw new Run.RunnerAbortedException();
Expand All @@ -400,6 +384,25 @@ public void onCompleted(Run run, TaskListener listener) {
throw new Run.RunnerAbortedException();
}
}

//Mask passwords
EnvInjectPasswordsMasker passwordsMasker = new EnvInjectPasswordsMasker();
passwordsMasker.maskPasswordsIfAny(build, logger, envVars);

//Add or override EnvInject Action
EnvInjectActionSetter envInjectActionSetter = new EnvInjectActionSetter(getNodeRootPath());
try {
envInjectActionSetter.addEnvVarsToEnvInjectBuildAction((AbstractBuild<?, ?>) run, envVars);
} catch (EnvInjectException e) {
logger.error("SEVERE ERROR occurs: " + e.getMessage());
throw new Run.RunnerAbortedException();
} catch (IOException e) {
logger.error("SEVERE ERROR occurs: " + e.getMessage());
throw new Run.RunnerAbortedException();
} catch (InterruptedException e) {
logger.error("SEVERE ERROR occurs: " + e.getMessage());
throw new Run.RunnerAbortedException();
}
}
}

Expand Down

0 comments on commit 1f0b603

Please sign in to comment.