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

Commit 1daefbb

Browse files
author
Nikhil Bhoski
committed
Updated as per review comments.
1 parent c9e7a8a commit 1daefbb

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ default ProcStarter getProcessToRunMatlabCommand(ProcStarter matlabLauncher, Fil
4444
targetWorkspace);
4545
} else {
4646
final String runnerScriptName = uniqueName + "\\run_matlab_command.bat";
47-
matlabLauncher.cmds(tmpDir + "\\" + runnerScriptName, "\"" + matlabCommand + "\"")
47+
matlabLauncher.cmds("cmd.exe","/C",tmpDir + "\\" + runnerScriptName, "\"" + matlabCommand + "\"")
4848
.stdout(listener);
4949
// Copy runner.bat for Windows platform in workspace.
5050
copyFileInWorkspace(MatlabBuilderConstants.BAT_RUNNER_SCRIPT, runnerScriptName,
@@ -87,12 +87,4 @@ default String getNodeSpecificTmpFolderPath(FilePath workspace) throws IOExcepti
8787
default String getUniqueNameForRunnerFile() {
8888
return UUID.randomUUID().toString();
8989
}
90-
91-
default Launcher getDecoratedLauncherForWindows(Launcher launcher) {
92-
//decorate the launcher if its on windows
93-
if(!launcher.isUnix()) {
94-
launcher = launcher.decorateByPrefix("cmd.exe", "/C");
95-
}
96-
return launcher;
97-
}
9890
}

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,13 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
118118
final String uniqueTmpFldrName = getUniqueNameForRunnerFile();
119119
final String uniqueCommandFile =
120120
"command_" + getUniqueNameForRunnerFile().replaceAll("-", "_");
121-
122-
// Get unique temporary folder filepath
123121
final FilePath uniqeTmpFolderPath =
124122
getFilePathForUniqueFolder(launcher, uniqueTmpFldrName, workspace);
125-
// Create a new command runner script in the temp folder.
126-
final FilePath matlabCommandFile =
127-
new FilePath(uniqeTmpFolderPath, uniqueCommandFile + ".m");
128-
final String matlabCommandFileContent =
129-
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + getCommand();
130-
131-
// Display the commands on console output for users reference
132-
listener.getLogger()
133-
.println("Generating MATLAB script with content:\n" + getCommand() + "\n");
123+
124+
// Create MATLAB script
125+
createMatlabScriptByName(uniqeTmpFolderPath,uniqueCommandFile,workspace,listener);
134126

135-
matlabCommandFile.write(matlabCommandFileContent, "UTF-8");
136127
try {
137-
launcher = getDecoratedLauncherForWindows(launcher);
138128
// Start the launcher from temp folder
139129
ProcStarter matlabLauncher = launcher.launch().pwd(uniqeTmpFolderPath).envs(envVars);
140130
listener.getLogger()
@@ -152,4 +142,19 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
152142
}
153143
}
154144
}
145+
146+
private void createMatlabScriptByName(FilePath uniqeTmpFolderPath, String uniqueScriptName, FilePath workspace, TaskListener listener) throws IOException, InterruptedException {
147+
148+
// Create a new command runner script in the temp folder.
149+
final FilePath matlabCommandFile =
150+
new FilePath(uniqeTmpFolderPath, uniqueScriptName + ".m");
151+
final String matlabCommandFileContent =
152+
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + getCommand();
153+
154+
// Display the commands on console output for users reference
155+
listener.getLogger()
156+
.println("Generating MATLAB script with content:\n" + getCommand() + "\n");
157+
158+
matlabCommandFile.write(matlabCommandFileContent, "UTF-8");
159+
}
155160
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,8 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
238238
final String uniqueTmpFldrName = getUniqueNameForRunnerFile();
239239
ProcStarter matlabLauncher;
240240
try {
241-
// Get decorated launcher for Windows
242-
launcher = getDecoratedLauncherForWindows(launcher);
243241
matlabLauncher = launcher.launch().pwd(workspace).envs(envVars);
244-
245-
242+
246243
// Copy MATLAB scratch file into the workspace.
247244
FilePath targetWorkspace = new FilePath(launcher.getChannel(), workspace.getRemote());
248245
copyFileInWorkspace(MatlabBuilderConstants.MATLAB_TESTS_RUNNER_RESOURCE,

0 commit comments

Comments
 (0)