Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit f4a5fba

Browse files
authored
Merge pull request #18 from mathworks/CI_244_env_variable_support
Fix to supoprt Jenkins environment variables.
2 parents 466c0d4 + 742a0df commit f4a5fba

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/com/mathworks/ci/MatlabBuilder.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import hudson.ExtensionPoint;
3232
import hudson.FilePath;
3333
import hudson.Launcher;
34+
import hudson.Launcher.ProcStarter;
3435
import hudson.model.AbstractProject;
3536
import hudson.model.Describable;
3637
import hudson.model.Descriptor;
@@ -389,21 +390,21 @@ private int execMatlabCommand(Run<?, ?> build, FilePath workspace, Launcher laun
389390
//Copy MATLAB scratch file into the workspace
390391
copyMatlabScratchFileInWorkspace(MATLAB_RUNNER_RESOURCE, MATLAB_RUNNER_TARGET_FILE,
391392
workspace, getClass().getClassLoader());
393+
ProcStarter matlabLauncher;
392394
try {
393395
MatlabReleaseInfo rel = new MatlabReleaseInfo(getLocalMatlab());
396+
matlabLauncher = launcher.launch().pwd(workspace).envs(env);
394397
if (rel.verLessThan(BASE_MATLAB_VERSION_BATCH_SUPPORT)) {
395398
ListenerLogDecorator outStream = new ListenerLogDecorator(listener);
396-
return launcher.launch().pwd(workspace)
397-
.cmds(constructDefaultMatlabCommand(isLinuxLauncher)).stderr(outStream)
398-
.join();
399+
matlabLauncher = matlabLauncher.cmds(constructDefaultMatlabCommand(isLinuxLauncher)).stderr(outStream);
399400
} else {
400-
return launcher.launch().pwd(workspace).cmds(constructMatlabCommandWithBatch())
401-
.stdout(listener).join();
401+
matlabLauncher = matlabLauncher.cmds(constructMatlabCommandWithBatch()).stdout(listener);
402402
}
403403
} catch (MatlabVersionNotFoundException e) {
404404
listener.getLogger().println(e.getMessage());
405405
return 1;
406406
}
407+
return matlabLauncher.join();
407408
}
408409

409410
public List<String> constructMatlabCommandWithBatch() {

0 commit comments

Comments
 (0)