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

Commit 04f428f

Browse files
committed
initial draft
1 parent 0b68cbb commit 04f428f

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public MatlabCommandStepExecution(StepContext context, String command) {
2424
}
2525

2626
private String getCommand() {
27-
return this.env == null ? this.command : this.env.expand(this.command );
27+
return this.command;
2828
}
2929

3030
private void setEnv(EnvVars env) {
@@ -37,7 +37,6 @@ public Void run() throws Exception {
3737
final FilePath workspace = getContext().get(FilePath.class);
3838
final TaskListener listener = getContext().get(TaskListener.class);
3939
final EnvVars env = getContext().get(EnvVars.class);
40-
setEnv(env);
4140

4241
//Make sure the Workspace exists before run
4342

@@ -59,7 +58,7 @@ public void stop(Throwable cause) throws Exception {
5958
getContext().onFailure(cause);
6059
}
6160

62-
private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher,
61+
private int execMatlabCommand(FilePath workspace, Launcher launcher,
6362
TaskListener listener, EnvVars envVars) throws IOException, InterruptedException {
6463
final String uniqueTmpFldrName = getUniqueNameForRunnerFile();
6564
final String uniqueCommandFile =
@@ -91,12 +90,13 @@ private void createMatlabScriptByName(FilePath uniqeTmpFolderPath, String unique
9190
// Create a new command runner script in the temp folder.
9291
final FilePath matlabCommandFile =
9392
new FilePath(uniqeTmpFolderPath, uniqueScriptName + ".m");
93+
final String cmd = getContext().get(EnvVars.class).expand(getCommand());
9494
final String matlabCommandFileContent =
95-
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + getCommand();
95+
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + cmd;
9696

9797
// Display the commands on console output for users reference
9898
listener.getLogger()
99-
.println("Generating MATLAB script with content:\n" + getCommand() + "\n");
99+
.println("Generating MATLAB script with content:\n" + cmd + "\n");
100100

101101
matlabCommandFile.write(matlabCommandFileContent, "UTF-8");
102102
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void stop(Throwable cause) throws Exception {
5858
getContext().onFailure(cause);
5959
}
6060

61-
private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher,
61+
private int execMatlabCommand(FilePath workspace, Launcher launcher,
6262
TaskListener listener, EnvVars envVars) throws IOException, InterruptedException {
6363
final String uniqueTmpFldrName = getUniqueNameForRunnerFile();
6464
try {

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,20 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
9797
throws InterruptedException, IOException {
9898

9999
// Set the environment variable specific to the this build
100-
setEnv(build.getEnvironment(listener));
100+
//setEnv(build.getEnvironment(listener));
101101

102102
// Invoke MATLAB command and transfer output to standard
103103
// Output Console
104104

105105

106-
buildResult = execMatlabCommand(workspace, launcher, listener, getEnv());
106+
buildResult = execMatlabCommand(workspace, launcher, listener, build.getEnvironment(listener));
107107

108108
if (buildResult != 0) {
109109
build.setResult(Result.FAILURE);
110110
}
111111
}
112112

113-
private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher,
113+
private int execMatlabCommand(FilePath workspace, Launcher launcher,
114114
TaskListener listener, EnvVars envVars) throws IOException, InterruptedException {
115115

116116
/*
@@ -126,7 +126,7 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
126126
getFilePathForUniqueFolder(launcher, uniqueTmpFldrName, workspace);
127127

128128
// Create MATLAB script
129-
createMatlabScriptByName(uniqeTmpFolderPath, uniqueCommandFile, workspace, listener);
129+
createMatlabScriptByName(uniqeTmpFolderPath, uniqueCommandFile, workspace, listener, envVars);
130130
ProcStarter matlabLauncher;
131131

132132
try {
@@ -148,17 +148,18 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
148148
}
149149
}
150150

151-
private void createMatlabScriptByName(FilePath uniqeTmpFolderPath, String uniqueScriptName, FilePath workspace, TaskListener listener) throws IOException, InterruptedException {
151+
private void createMatlabScriptByName(FilePath uniqeTmpFolderPath, String uniqueScriptName, FilePath workspace, TaskListener listener, EnvVars envVars) throws IOException, InterruptedException {
152152

153153
// Create a new command runner script in the temp folder.
154154
final FilePath matlabCommandFile =
155155
new FilePath(uniqeTmpFolderPath, uniqueScriptName + ".m");
156+
final String cmd = envVars.expand(getMatlabCommand());
156157
final String matlabCommandFileContent =
157-
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + getCommand();
158+
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + cmd;
158159

159160
// Display the commands on console output for users reference
160161
listener.getLogger()
161-
.println("Generating MATLAB script with content:\n" + getCommand() + "\n");
162+
.println("Generating MATLAB script with content:\n" + cmd + "\n");
162163

163164
matlabCommandFile.write(matlabCommandFileContent, "UTF-8");
164165
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,19 +258,19 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
258258
throws InterruptedException, IOException {
259259

260260
// Set the environment variable specific to the this build
261-
setEnv(build.getEnvironment(listener));
261+
//setEnv(build.getEnvironment(listener));
262262

263263
// Invoke MATLAB command and transfer output to standard
264264
// Output Console
265265

266-
buildResult = execMatlabCommand(workspace, launcher, listener, getEnv());
266+
buildResult = execMatlabCommand(workspace, launcher, listener, build.getEnvironment(listener));
267267

268268
if (buildResult != 0) {
269269
build.setResult(Result.FAILURE);
270270
}
271271
}
272272

273-
private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher,
273+
private int execMatlabCommand(FilePath workspace, Launcher launcher,
274274
TaskListener listener, EnvVars envVars) throws IOException, InterruptedException {
275275

276276
/*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public FormValidation doCheckMatlabRootFolder(@QueryParameter String matlabRootF
175175
}
176176

177177
@Override
178-
public synchronized void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher launcher,
178+
public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher launcher,
179179
TaskListener listener, EnvVars initialEnvironment)
180180
throws IOException, InterruptedException {
181181
// Set Environment variable

0 commit comments

Comments
 (0)