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

Commit 9c08600

Browse files
committed
Revoked support for windows and other comments
1 parent c29ae44 commit 9c08600

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,19 @@ public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher
188188
// Set Environment variable
189189
setEnv(initialEnvironment);
190190

191-
FilePath matlabExecutablePath = new FilePath(launcher.getChannel(),
192-
getNodeSpecificMatlab(Computer.currentComputer(), listener) + getNodeSpecificExecutable(launcher));
191+
String nodeSpecificMatlab = getNodeSpecificMatlab(Computer.currentComputer(), listener) + getNodeSpecificExecutable(launcher);
192+
FilePath matlabExecutablePath = new FilePath(launcher.getChannel(), nodeSpecificMatlab);
193193

194194
if (!matlabExecutablePath.exists()) {
195195
throw new MatlabNotFoundError(Message.getValue("matlab.not.found.error"));
196196
}
197197
// Add matlab-batch executable in path
198-
context.env("PATH+matlab_batch", matlabExecutablePath.getParent().getParent().getRemote());
198+
if(getNthParentFilePath(matlabExecutablePath, 3).exists () || getNthParentFilePath(matlabExecutablePath,3 ) != null){
199+
context.env("PATH+matlab_batch", matlabExecutablePath.getParent ().getParent ().getParent().getRemote ());
200+
}
201+
199202
// Add "matlabroot" without bin as env variable which will be available across the build.
200-
context.env("matlabroot", getNodeSpecificMatlab(Computer.currentComputer(), listener));
203+
context.env("matlabroot", nodeSpecificMatlab);
201204
// Add matlab bin to path to invoke MATLAB directly on command line.
202205
context.env("PATH+matlabroot", matlabExecutablePath.getParent().getRemote());;
203206
listener.getLogger().println("\n" + String.format(Message.getValue("matlab.added.to.path.from"), matlabExecutablePath.getParent().getRemote()) + "\n");
@@ -206,4 +209,20 @@ public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher
206209
private String getNodeSpecificExecutable(Launcher launcher) {
207210
return (launcher.isUnix()) ? "/bin/matlab" : "\\bin\\matlab.exe";
208211
}
212+
213+
public static FilePath getNthParentFilePath (FilePath path, int levels) {
214+
if (path == null || levels < 0) {
215+
return null;
216+
}
217+
218+
FilePath currentPath = path;
219+
for (int i = 0; i < levels; i++) {
220+
if (currentPath == null) {
221+
return null;
222+
}
223+
currentPath = currentPath.getParent ();
224+
}
225+
return currentPath;
226+
}
227+
209228
}

src/main/java/com/mathworks/ci/tools/MatlabInstaller.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,17 @@ public void setProducts (String products) {
7676
@Override
7777
public FilePath performInstallation (ToolInstallation tool, Node node, TaskListener log)
7878
throws IOException, InterruptedException {
79-
FilePath expectedPath = preferredLocation (tool, node);
79+
FilePath supportingExecutable = preferredLocation (tool, node);
80+
FilePath expectedPath = new FilePath (supportingExecutable, this.getVersion ());
8081
MatlabInstallable installable;
8182
try {
8283
installable = (MatlabInstallable) getInstallable (node);
8384
} catch (Exception e) {
8485
throw new InstallationFailedException (e.getMessage ());
8586
}
8687

87-
getFreshCopyOfExecutables (installable, expectedPath);
88+
getFreshCopyOfExecutables (installable, supportingExecutable);
89+
makeDir (expectedPath);
8890

8991
FilePath versionInfo = new FilePath (expectedPath,"VersionInfo.xml");
9092
FilePath installedProducts = new FilePath (expectedPath,"installed_matlab_product_list.txt");
@@ -109,7 +111,7 @@ private int installUsingMpm (Node node, FilePath destination, TaskListener log,
109111
ProcStarter installerProc = matlabInstaller.launch ();
110112

111113
ArgumentListBuilder args = new ArgumentListBuilder ();
112-
args.add (destination.getRemote () + getNodeSpecificMPMExecutor (node));
114+
args.add (destination.getParent ().getRemote () + getNodeSpecificMPMExecutor (node));
113115
args.add ("install");
114116
appendReleaseToArguments (args, log);
115117
args.add ("--destination=" + destination.getRemote ());
@@ -119,12 +121,19 @@ private int installUsingMpm (Node node, FilePath destination, TaskListener log,
119121
try {
120122
result = installerProc.join ();
121123
} catch (Exception e) {
122-
log.getLogger ().println ("MATLAB installation failed" + e.getMessage ());
124+
log.getLogger ().println ("MATLAB installation failed " + e.getMessage ());
123125
throw new InstallationFailedException (e.getMessage ());
124126
}
125127
return result;
126128
}
127129

130+
private void makeDir(FilePath path) throws IOException, InterruptedException {
131+
if(!path.exists ()){
132+
path.mkdirs ();
133+
path.chmod (0777);
134+
}
135+
}
136+
128137
private boolean isSameProduct (FilePath installedProducts)
129138
throws IOException, InterruptedException {
130139
if (installedProducts.exists ()) {
@@ -250,6 +259,9 @@ public Installable getInstallable (Node node) throws IOException, InterruptedExc
250259
// Gather properties for the node to install on
251260
String[] properties = node.getChannel ()
252261
.call (new GetSystemProperties ("os.name", "os.arch", "os.version"));
262+
if(properties[0].contains ("win")) {
263+
throw new InstallationFailedException ("Unsupported OS");
264+
}
253265
return getInstallCandidate (properties[0], properties[1]);
254266
}
255267

0 commit comments

Comments
 (0)