1414import hudson .FilePath ;
1515import hudson .Launcher ;
1616import hudson .Launcher .ProcStarter ;
17+ import hudson .util .ArgumentListBuilder ;
1718import hudson .model .TaskListener ;
1819
1920public interface MatlabBuild {
@@ -35,6 +36,7 @@ default ProcStarter getProcessToRunMatlabCommand(FilePath workspace,
3536 // Get node specific temp .matlab directory to copy matlab runner script
3637 FilePath targetWorkspace ;
3738 ProcStarter matlabLauncher ;
39+ ArgumentListBuilder args = new ArgumentListBuilder ();
3840 if (launcher .isUnix ()) {
3941 targetWorkspace = new FilePath (launcher .getChannel (),
4042 workspace .getRemote () + "/" + MatlabBuilderConstants .TEMP_MATLAB_FOLDER_NAME );
@@ -55,8 +57,11 @@ default ProcStarter getProcessToRunMatlabCommand(FilePath workspace,
5557 binaryName = "maci64/run-matlab-command" ;
5658 }
5759
58- matlabLauncher = launcher .launch ().envs (envVars );
59- matlabLauncher .cmds (MatlabBuilderConstants .TEMP_MATLAB_FOLDER_NAME + "/" + runnerName , matlabCommand , startupOpts ).stdout (listener );
60+ args .add (MatlabBuilderConstants .TEMP_MATLAB_FOLDER_NAME + "/" + runnerName );
61+ args .add (matlabCommand );
62+ args .add (startupOpts .split (" " ));
63+
64+ matlabLauncher = launcher .launch ().envs (envVars ).cmds (args ).stdout (listener );
6065
6166 // Copy runner for linux platform in workspace.
6267 copyFileInWorkspace (binaryName , runnerName , targetWorkspace );
@@ -65,9 +70,11 @@ default ProcStarter getProcessToRunMatlabCommand(FilePath workspace,
6570 workspace .getRemote () + "\\ " + MatlabBuilderConstants .TEMP_MATLAB_FOLDER_NAME );
6671
6772 final String runnerName = uniqueName + "\\ run-matlab-command.exe" ;
68- matlabLauncher = launcher .launch ().envs (envVars );
69- matlabLauncher .cmds (targetWorkspace .toString () + "\\ " + runnerName , "\" " + matlabCommand + "\" " , startupOpts )
70- .stdout (listener );
73+
74+ args .add (targetWorkspace .toString () + "\\ " + runnerName , "\" " + matlabCommand + "\" " );
75+ args .add (startupOpts .split (" " ));
76+
77+ matlabLauncher = launcher .launch ().envs (envVars ).cmds (args ).stdout (listener );
7178
7279 // Copy runner for Windows platform in workspace.
7380 copyFileInWorkspace ("win64/run-matlab-command.exe" , runnerName ,
0 commit comments