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

Commit 9caee0d

Browse files
authored
Merge pull request #195 from mathworks/2.5.1-SNAPSHOT-Qualification
2.5.1 snapshot qualification
2 parents 09eb5df + 5eb257d commit 9caee0d

File tree

5 files changed

+20
-46
lines changed

5 files changed

+20
-46
lines changed

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class MatlabCommandStepExecution extends SynchronousNonBlockingStepExecut
1515
private static final long serialVersionUID = 1957239693658914450L;
1616

1717
private String command;
18-
private EnvVars env;
1918

2019

2120
public MatlabCommandStepExecution(StepContext context, String command) {
@@ -24,11 +23,7 @@ public MatlabCommandStepExecution(StepContext context, String command) {
2423
}
2524

2625
private String getCommand() {
27-
return this.env == null ? this.command : this.env.expand(this.command );
28-
}
29-
30-
private void setEnv(EnvVars env) {
31-
this.env = env;
26+
return this.command;
3227
}
3328

3429
@Override
@@ -37,7 +32,6 @@ public Void run() throws Exception {
3732
final FilePath workspace = getContext().get(FilePath.class);
3833
final TaskListener listener = getContext().get(TaskListener.class);
3934
final EnvVars env = getContext().get(EnvVars.class);
40-
setEnv(env);
4135

4236
//Make sure the Workspace exists before run
4337

@@ -59,7 +53,7 @@ public void stop(Throwable cause) throws Exception {
5953
getContext().onFailure(cause);
6054
}
6155

62-
private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher,
56+
private int execMatlabCommand(FilePath workspace, Launcher launcher,
6357
TaskListener listener, EnvVars envVars) throws IOException, InterruptedException {
6458
final String uniqueTmpFldrName = getUniqueNameForRunnerFile();
6559
final String uniqueCommandFile =
@@ -91,12 +85,13 @@ private void createMatlabScriptByName(FilePath uniqeTmpFolderPath, String unique
9185
// Create a new command runner script in the temp folder.
9286
final FilePath matlabCommandFile =
9387
new FilePath(uniqeTmpFolderPath, uniqueScriptName + ".m");
88+
final String cmd = getContext().get(EnvVars.class).expand(getCommand());
9489
final String matlabCommandFileContent =
95-
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + getCommand();
90+
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + cmd;
9691

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

10196
matlabCommandFile.write(matlabCommandFileContent, "UTF-8");
10297
}

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: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
public class RunMatlabCommandBuilder extends Builder implements SimpleBuildStep, MatlabBuild {
3030
private int buildResult;
31-
private EnvVars env;
3231
private String matlabCommand;
3332

3433
@DataBoundConstructor
@@ -48,19 +47,6 @@ public void setMatlabCommand(String matlabCommand) {
4847
public String getMatlabCommand() {
4948
return this.matlabCommand;
5049
}
51-
52-
private String getCommand() {
53-
return this.env == null ? getMatlabCommand() : this.env.expand(getMatlabCommand());
54-
}
55-
56-
private void setEnv(EnvVars env) {
57-
this.env = env;
58-
}
59-
60-
private EnvVars getEnv() {
61-
return this.env;
62-
}
63-
6450

6551
@Extension
6652
public static class RunMatlabCommandDescriptor extends BuildStepDescriptor<Builder> {
@@ -96,21 +82,21 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
9682
@Nonnull Launcher launcher, @Nonnull TaskListener listener)
9783
throws InterruptedException, IOException {
9884

99-
// Set the environment variable specific to the this build
100-
setEnv(build.getEnvironment(listener));
85+
// Get the environment variable specific to the this build
86+
final EnvVars env = build.getEnvironment(listener);
10187

10288
// Invoke MATLAB command and transfer output to standard
10389
// Output Console
10490

10591

106-
buildResult = execMatlabCommand(workspace, launcher, listener, getEnv());
92+
buildResult = execMatlabCommand(workspace, launcher, listener, env);
10793

10894
if (buildResult != 0) {
10995
build.setResult(Result.FAILURE);
11096
}
11197
}
11298

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

116102
/*
@@ -126,7 +112,7 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
126112
getFilePathForUniqueFolder(launcher, uniqueTmpFldrName, workspace);
127113

128114
// Create MATLAB script
129-
createMatlabScriptByName(uniqeTmpFolderPath, uniqueCommandFile, workspace, listener);
115+
createMatlabScriptByName(uniqeTmpFolderPath, uniqueCommandFile, workspace, listener, envVars);
130116
ProcStarter matlabLauncher;
131117

132118
try {
@@ -148,17 +134,18 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
148134
}
149135
}
150136

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

153139
// Create a new command runner script in the temp folder.
154140
final FilePath matlabCommandFile =
155141
new FilePath(uniqeTmpFolderPath, uniqueScriptName + ".m");
142+
final String cmd = envVars.expand(getMatlabCommand());
156143
final String matlabCommandFileContent =
157-
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + getCommand();
144+
"cd '" + workspace.getRemote().replaceAll("'", "''") + "';\n" + cmd;
158145

159146
// Display the commands on console output for users reference
160147
listener.getLogger()
161-
.println("Generating MATLAB script with content:\n" + getCommand() + "\n");
148+
.println("Generating MATLAB script with content:\n" + cmd + "\n");
162149

163150
matlabCommandFile.write(matlabCommandFileContent, "UTF-8");
164151
}

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
public class RunMatlabTestsBuilder extends Builder implements SimpleBuildStep, MatlabBuild {
4242

4343
private int buildResult;
44-
private EnvVars env;
4544

4645
// Make all old values transient which protects them writing back on disk.
4746
private transient boolean tapChkBx;
@@ -179,13 +178,6 @@ private Artifact getArtifactObject(boolean isChecked, Artifact returnVal) {
179178
return (isChecked) ? returnVal : new NullArtifact();
180179
}
181180

182-
private void setEnv(EnvVars env) {
183-
this.env = env;
184-
}
185-
186-
private EnvVars getEnv() {
187-
return this.env;
188-
}
189181

190182
// To retain Backward compatibility
191183
protected Object readResolve() {
@@ -257,20 +249,20 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
257249
@Nonnull Launcher launcher, @Nonnull TaskListener listener)
258250
throws InterruptedException, IOException {
259251

260-
// Set the environment variable specific to the this build
261-
setEnv(build.getEnvironment(listener));
252+
// Get the environment variable specific to the this build
253+
final EnvVars env = build.getEnvironment(listener);
262254

263255
// Invoke MATLAB command and transfer output to standard
264256
// Output Console
265257

266-
buildResult = execMatlabCommand(workspace, launcher, listener, getEnv());
258+
buildResult = execMatlabCommand(workspace, launcher, listener, env);
267259

268260
if (buildResult != 0) {
269261
build.setResult(Result.FAILURE);
270262
}
271263
}
272264

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

276268
/*

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)