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

Commit 1ae7852

Browse files
author
Nikhil Bhoski
committed
Replaced use of Computers to workspace.toComputer()
1 parent 1feebaa commit 1ae7852

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ default ProcStarter getProcessToRunMatlabCommand(FilePath workspace, Launcher la
3333
TaskListener listener, EnvVars envVars, String matlabCommand, String uniqueName)
3434
throws IOException, InterruptedException {
3535
// Get node specific tmp directory to copy matlab runner script
36-
String tmpDir = getNodeSpecificTmpFolderPath();
36+
String tmpDir = getNodeSpecificTmpFolderPath(workspace);
3737
FilePath targetWorkspace = new FilePath(launcher.getChannel(), tmpDir);
3838
ProcStarter matlabLauncher;
3939
if (launcher.isUnix()) {
@@ -70,9 +70,12 @@ default void copyFileInWorkspace(String sourceFile, String targetFile, FilePath
7070
targetFilePath.chmod(0755);
7171
}
7272

73-
default FilePath getFilePathForUniqueFolder(Launcher launcher, String uniqueName)
73+
default FilePath getFilePathForUniqueFolder(Launcher launcher, String uniqueName,FilePath workspace)
7474
throws IOException, InterruptedException {
75-
Computer cmp = Computer.currentComputer();
75+
/*Use of Computer is not recommended as jenkins hygeine for pipeline support
76+
* https://javadoc.jenkins-ci.org/jenkins/tasks/SimpleBuildStep.html */
77+
78+
Computer cmp = workspace.toComputer();
7679
String tmpDir = (String) cmp.getSystemProperties().get("java.io.tmpdir");
7780
if (launcher.isUnix()) {
7881
tmpDir = tmpDir + "/" + uniqueName;
@@ -82,8 +85,8 @@ default FilePath getFilePathForUniqueFolder(Launcher launcher, String uniqueName
8285
return new FilePath(launcher.getChannel(), tmpDir);
8386
}
8487

85-
default String getNodeSpecificTmpFolderPath() throws IOException, InterruptedException {
86-
Computer cmp = Computer.currentComputer();
88+
default String getNodeSpecificTmpFolderPath(FilePath workspace) throws IOException, InterruptedException {
89+
Computer cmp = workspace.toComputer();
8790
String tmpDir = (String) cmp.getSystemProperties().get("java.io.tmpdir");
8891
return tmpDir;
8992
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
122122
return 1;
123123
} finally {
124124
// Cleanup the runner File from tmp directory
125-
FilePath matlabRunnerScript = getFilePathForUniqueFolder(launcher, uniqueTmpFldrName);
125+
FilePath matlabRunnerScript =
126+
getFilePathForUniqueFolder(launcher, uniqueTmpFldrName, workspace);
126127
if (matlabRunnerScript.exists()) {
127128
matlabRunnerScript.deleteRecursive();
128129
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
299299
return 1;
300300
} finally {
301301
// Cleanup the runner File from tmp directory
302-
FilePath matlabRunnerScript = getFilePathForUniqueFolder(launcher, uniqueTmpFldrName);
302+
FilePath matlabRunnerScript =
303+
getFilePathForUniqueFolder(launcher, uniqueTmpFldrName, workspace);
303304
if (matlabRunnerScript.exists()) {
304305
matlabRunnerScript.deleteRecursive();
305306
}
306307
}
307-
308308
}
309309

310310
public String constructCommandForTest(String inputArguments) {

0 commit comments

Comments
 (0)