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

Commit 25b9ca0

Browse files
author
Nikhil Bhoski
committed
Fixed findbug issue and FileCopy issue for Matlab test builder.
1 parent c1d84de commit 25b9ca0

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import java.io.IOException;
1010
import java.io.InputStream;
1111
import java.util.UUID;
12-
import javax.annotation.Nonnull;
13-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
1412
import hudson.EnvVars;
1513
import hudson.FilePath;
1614
import hudson.Launcher;
@@ -72,15 +70,12 @@ default void copyFileInWorkspace(String sourceFile, String targetFile, FilePath
7270
targetFilePath.chmod(0755);
7371
}
7472

75-
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
76-
justification = "workspace is passed through perform method, which will always have NonNull FilePath")
7773
default FilePath getFilePathForUniqueFolder(Launcher launcher, String uniqueName, FilePath workspace)
7874
throws IOException, InterruptedException {
7975
/*Use of Computer is not recommended as jenkins hygeine for pipeline support
8076
* https://javadoc.jenkins-ci.org/jenkins/tasks/SimpleBuildStep.html */
8177

82-
Computer cmp = workspace.toComputer();
83-
String tmpDir = (String) cmp.getSystemProperties().get("java.io.tmpdir");
78+
String tmpDir = getNodeSpecificTmpFolderPath(workspace);
8479
if (launcher.isUnix()) {
8580
tmpDir = tmpDir + "/" + uniqueName;
8681
} else {
@@ -89,16 +84,16 @@ default FilePath getFilePathForUniqueFolder(Launcher launcher, String uniqueName
8984
return new FilePath(launcher.getChannel(), tmpDir);
9085
}
9186

92-
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
93-
justification = "workspace is passed through perform method, which will always have NonNull FilePath")
9487
default String getNodeSpecificTmpFolderPath(FilePath workspace) throws IOException, InterruptedException {
9588
Computer cmp = workspace.toComputer();
89+
if (cmp == null) {
90+
throw new IOException(Message.getValue("build.workspace.computer.not.found"));
91+
}
9692
String tmpDir = (String) cmp.getSystemProperties().get("java.io.tmpdir");
9793
return tmpDir;
9894
}
9995

10096
default String getUniqueNameForRunnerFile() {
10197
return UUID.randomUUID().toString();
10298
}
103-
10499
}

src/main/resources/config.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ Builder.matlab.modelcoverage.support.warning = To generate a Cobertura model cov
1616
Builder.matlab.exportstmresults.support.warning = To export Simulink Test Manager results, use MATLAB R2019a or a newer release.
1717
Builder.matlab.runner.script.target.file.linux.name = run_matlab_command.sh
1818
Builder.matlab.runner.script.target.file.windows.name = run_matlab_command.bat
19+
build.workspace.computer.not.found = Unable to get the current computer for this build.
1920

0 commit comments

Comments
 (0)