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

Commit 3517803

Browse files
committed
add null check
1 parent 40a7af4 commit 3517803

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,18 @@ public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher
204204
if (!matlabExecutablePath.exists()) {
205205
throw new MatlabNotFoundError(Message.getValue("matlab.not.found.error"));
206206
}
207+
208+
FilePath matlabBinPath = matlabExecutablePath.getParent();
209+
if (matlabBinPath == null) {
210+
throw new IOException("Failed to get MATLAB bin directory");
211+
}
207212

208213
// Add "matlabroot" without bin as env variable which will be available across the build.
209214
context.env("matlabroot", nodeSpecificMatlab);
210215
// Add matlab bin to path to invoke MATLAB directly on command line.
211-
context.env("PATH+matlabroot", matlabExecutablePath.getParent().getRemote());
216+
context.env("PATH+matlabroot", matlabBinPath.getRemote());
212217
// Specify which MATLAB was added to path.
213-
listener.getLogger().println("\n" + String.format(Message.getValue("matlab.added.to.path.from"), matlabExecutablePath.getParent().getRemote()) + "\n");
218+
listener.getLogger().println("\n" + String.format(Message.getValue("matlab.added.to.path.from"), matlabBinPath.getRemote()) + "\n");
214219
}
215220

216221
private String getNodeSpecificExecutable(Launcher launcher) {

0 commit comments

Comments
 (0)