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

Commit 8074db2

Browse files
committed
Initial fix
1 parent 248e90b commit 8074db2

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ private int execMatlabCommand(FilePath workspace, Launcher launcher,
6868
getFilePathForUniqueFolder(launcher, uniqueTmpFldrName, workspace);
6969

7070
// Create MATLAB script
71-
createMatlabScriptByName(uniqueTmpFolderPath, uniqueBuildFile, workspace, listener);
71+
createMatlabScriptByName(uniqueTmpFolderPath, uniqueBuildFile, listener);
7272
ProcStarter matlabLauncher;
7373

7474
try {
7575
matlabLauncher = getProcessToRunMatlabCommand(workspace, launcher, listener, envVars,
76-
"cd('"+ uniqueTmpFolderPath.getRemote().replaceAll("'", "''") +"'); "+ uniqueBuildFile, startupOptions, uniqueTmpFldrName);
76+
"setenv('MW_ORIG_WORKING_FOLDER', cd('"+ uniqueTmpFolderPath.getRemote().replaceAll("'", "''") +"')); "+ uniqueBuildFile, startupOptions, uniqueTmpFldrName);
7777
listener.getLogger()
7878
.println("#################### Starting command output ####################");
7979
return matlabLauncher.pwd(workspace).join();
@@ -86,7 +86,7 @@ private int execMatlabCommand(FilePath workspace, Launcher launcher,
8686
}
8787
}
8888

89-
private void createMatlabScriptByName(FilePath uniqueTmpFolderPath, String uniqueScriptName, FilePath workspace, TaskListener listener) throws IOException, InterruptedException {
89+
private void createMatlabScriptByName(FilePath uniqueTmpFolderPath, String uniqueScriptName, TaskListener listener) throws IOException, InterruptedException {
9090

9191
// Create a new command runner script in the temp folder.
9292
final FilePath matlabBuildFile =
@@ -98,7 +98,7 @@ private void createMatlabScriptByName(FilePath uniqueTmpFolderPath, String uniqu
9898
cmd += " " + tasks;
9999
}
100100
final String matlabBuildFileContent =
101-
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + cmd;
101+
"cd(getenv('MW_ORIG_WORKING_FOLDER'));\n" + cmd;
102102

103103
// Display the commands on console output for users reference
104104
listener.getLogger()

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ private int execMatlabCommand(FilePath workspace, Launcher launcher,
6969
getFilePathForUniqueFolder(launcher, uniqueTmpFldrName, workspace);
7070

7171
// Create MATLAB script
72-
createMatlabScriptByName(uniqueTmpFolderPath, uniqueCommandFile, workspace, listener);
72+
createMatlabScriptByName(uniqueTmpFolderPath, uniqueCommandFile, listener);
7373
ProcStarter matlabLauncher;
7474

7575
try {
7676
matlabLauncher = getProcessToRunMatlabCommand(workspace, launcher, listener, envVars,
77-
"cd('"+ uniqueTmpFolderPath.getRemote().replaceAll("'", "''") +"'); "+ uniqueCommandFile, startupOptions, uniqueTmpFldrName);
77+
"setenv('MW_ORIG_WORKING_FOLDER', cd('"+ uniqueTmpFolderPath.getRemote().replaceAll("'", "''") +"')); "+ uniqueCommandFile, startupOptions, uniqueTmpFldrName);
7878
listener.getLogger()
7979
.println("#################### Starting command output ####################");
8080
return matlabLauncher.pwd(workspace).join();
@@ -87,14 +87,14 @@ private int execMatlabCommand(FilePath workspace, Launcher launcher,
8787
}
8888
}
8989

90-
private void createMatlabScriptByName(FilePath uniqueTmpFolderPath, String uniqueScriptName, FilePath workspace, TaskListener listener) throws IOException, InterruptedException {
90+
private void createMatlabScriptByName(FilePath uniqueTmpFolderPath, String uniqueScriptName, TaskListener listener) throws IOException, InterruptedException {
9191

9292
// Create a new command runner script in the temp folder.
9393
final FilePath matlabCommandFile =
9494
new FilePath(uniqueTmpFolderPath, uniqueScriptName + ".m");
9595
final String cmd = getContext().get(EnvVars.class).expand(getCommand());
9696
final String matlabCommandFileContent =
97-
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + cmd;
97+
"cd(getenv('MW_ORIG_WORKING_FOLDER'));\n" + cmd;
9898

9999
// Display the commands on console output for users reference
100100
listener.getLogger()

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ private int execMatlabCommand(FilePath workspace, Launcher launcher,
117117
getFilePathForUniqueFolder(launcher, uniqueTmpFldrName, workspace);
118118

119119
// Create MATLAB script
120-
createMatlabScriptByName(uniqueTmpFolderPath, uniqueBuildFile, workspace, listener, envVars);
120+
createMatlabScriptByName(uniqueTmpFolderPath, uniqueBuildFile, listener, envVars);
121121
ProcStarter matlabLauncher;
122122
String options = getStartupOptions() == null ? "" : getStartupOptions().getOptions();
123123
try {
124124
matlabLauncher = getProcessToRunMatlabCommand(workspace, launcher, listener, envVars,
125-
"cd('"+ uniqueTmpFolderPath.getRemote().replaceAll("'", "''") +"');"+ uniqueBuildFile, options, uniqueTmpFldrName);
125+
"setenv('MW_ORIG_WORKING_FOLDER', cd('"+ uniqueTmpFolderPath.getRemote().replaceAll("'", "''") +"'));"+ uniqueBuildFile, options, uniqueTmpFldrName);
126126

127127
listener.getLogger()
128128
.println("#################### Starting command output ####################");
@@ -139,7 +139,7 @@ private int execMatlabCommand(FilePath workspace, Launcher launcher,
139139
}
140140
}
141141

142-
private void createMatlabScriptByName(FilePath uniqueTmpFolderPath, String uniqueScriptName, FilePath workspace, TaskListener listener, EnvVars envVars) throws IOException, InterruptedException {
142+
private void createMatlabScriptByName(FilePath uniqueTmpFolderPath, String uniqueScriptName, TaskListener listener, EnvVars envVars) throws IOException, InterruptedException {
143143

144144
// Create a new command runner script in the temp folder.
145145
final FilePath matlabCommandFile =
@@ -152,7 +152,7 @@ private void createMatlabScriptByName(FilePath uniqueTmpFolderPath, String uniqu
152152
}
153153

154154
final String matlabCommandFileContent =
155-
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + cmd;
155+
"cd(getenv('MW_ORIG_WORKING_FOLDER'));\n" + cmd;
156156

157157
// Display the commands on console output for users reference
158158
listener.getLogger()

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ private int execMatlabCommand(FilePath workspace, Launcher launcher,
122122
getFilePathForUniqueFolder(launcher, uniqueTmpFldrName, workspace);
123123

124124
// Create MATLAB script
125-
createMatlabScriptByName(uniqueTmpFolderPath, uniqueCommandFile, workspace, listener, envVars);
125+
createMatlabScriptByName(uniqueTmpFolderPath, uniqueCommandFile, listener, envVars);
126126
ProcStarter matlabLauncher;
127127
String options = getStartupOptions() == null ? "" : getStartupOptions().getOptions();
128128

129129
try {
130130
matlabLauncher = getProcessToRunMatlabCommand(workspace, launcher, listener, envVars,
131-
"cd('"+ uniqueTmpFolderPath.getRemote().replaceAll("'", "''") +"');"+ uniqueCommandFile, options, uniqueTmpFldrName);
131+
"setenv('MW_ORIG_WORKING_FOLDER', cd('"+ uniqueTmpFolderPath.getRemote().replaceAll("'", "''") +"'));"+ uniqueCommandFile, options, uniqueTmpFldrName);
132132

133133
listener.getLogger()
134134
.println("#################### Starting command output ####################");
@@ -145,14 +145,14 @@ private int execMatlabCommand(FilePath workspace, Launcher launcher,
145145
}
146146
}
147147

148-
private void createMatlabScriptByName(FilePath uniqueTmpFolderPath, String uniqueScriptName, FilePath workspace, TaskListener listener, EnvVars envVars) throws IOException, InterruptedException {
148+
private void createMatlabScriptByName(FilePath uniqueTmpFolderPath, String uniqueScriptName, TaskListener listener, EnvVars envVars) throws IOException, InterruptedException {
149149

150150
// Create a new command runner script in the temp folder.
151151
final FilePath matlabCommandFile =
152152
new FilePath(uniqueTmpFolderPath, uniqueScriptName + ".m");
153153
final String cmd = envVars.expand(getMatlabCommand());
154154
final String matlabCommandFileContent =
155-
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + cmd;
155+
"cd(getenv('MW_ORIG_WORKING_FOLDER'));\n" + cmd;
156156

157157
// Display the commands on console output for users reference
158158
listener.getLogger()

0 commit comments

Comments
 (0)