Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix JENKINS-43175 NPE at hudson.plugins.cmake.CmakeBuilder.perform
  • Loading branch information
15knots committed Mar 31, 2017
1 parent 9808f1b commit 9a83889
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions src/main/java/hudson/plugins/cmake/CmakeBuilder.java
Expand Up @@ -54,7 +54,7 @@ public class CmakeBuilder extends AbstractCmakeBuilder {
private transient String buildDir;
private transient String cmakeArgs;

private List<BuildToolStep> toolSteps = new ArrayList<BuildToolStep>(0);
private List<BuildToolStep> toolSteps;

/**
* Minimal constructor.
Expand Down Expand Up @@ -262,27 +262,29 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
}

/* invoke each build tool step in build dir */
for (BuildToolStep step : toolSteps) {
ArgumentListBuilder toolCall;
if (!step.getWithCmake()) {
// invoke directly
// if buildTool == null, let the unexpanded macro show up in
// the log
final String buildToolMacro = Util.replaceMacro("${"
+ CmakeBuilder.ENV_VAR_NAME_CMAKE_BUILD_TOOL + "}",
envs);
toolCall = buildBuildToolCall(buildToolMacro,
step.getCommandArguments(envs));
} else {
// invoke through 'cmake --build <dir>'
toolCall = buildBuildToolCallWithCmake(cmakeBin,
theBuildDir, step.getCommandArguments(envs));
}
final EnvVars stepEnv = new EnvVars(envs)
.overrideAll(step.getEnvironmentVars(envs, listener));
if (0 != launcher.launch().pwd(theBuildDir).envs(stepEnv)
.stdout(listener).cmds(toolCall).join()) {
return false; // invocation failed
if( toolSteps != null) {
for (BuildToolStep step : toolSteps) {
ArgumentListBuilder toolCall;
if (!step.getWithCmake()) {
// invoke directly
// if buildTool == null, let the unexpanded macro show up in
// the log
final String buildToolMacro = Util.replaceMacro("${"
+ CmakeBuilder.ENV_VAR_NAME_CMAKE_BUILD_TOOL + "}",
envs);
toolCall = buildBuildToolCall(buildToolMacro,
step.getCommandArguments(envs));
} else {
// invoke through 'cmake --build <dir>'
toolCall = buildBuildToolCallWithCmake(cmakeBin,
theBuildDir, step.getCommandArguments(envs));
}
final EnvVars stepEnv = new EnvVars(envs)
.overrideAll(step.getEnvironmentVars(envs, listener));
if (0 != launcher.launch().pwd(theBuildDir).envs(stepEnv)
.stdout(listener).cmds(toolCall).join()) {
return false; // invocation failed
}
}
}
} catch (IOException e) {
Expand Down

0 comments on commit 9a83889

Please sign in to comment.