|
7 | 7 | * |
8 | 8 | */ |
9 | 9 |
|
| 10 | +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
10 | 11 | import hudson.CopyOnWrite; |
11 | 12 | import hudson.EnvVars; |
12 | 13 | import hudson.Extension; |
|
15 | 16 | import hudson.model.EnvironmentSpecific; |
16 | 17 | import hudson.model.Node; |
17 | 18 | import hudson.model.TaskListener; |
| 19 | +import hudson.remoting.VirtualChannel; |
18 | 20 | import hudson.slaves.NodeSpecific; |
19 | 21 | import hudson.tools.ToolDescriptor; |
20 | 22 | import hudson.tools.ToolInstallation; |
@@ -59,14 +61,23 @@ public MatlabInstallation forNode(@Nonnull Node node, TaskListener log) throws I |
59 | 61 | return new MatlabInstallation(getName(), translateFor(node, log), getProperties().toList()); |
60 | 62 | } |
61 | 63 |
|
| 64 | + @SuppressFBWarnings(value = {"NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"}, |
| 65 | + justification = |
| 66 | + "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE: Its false positive scenario for sport bug which is fixed in later versions " |
| 67 | + + "https://github.com/spotbugs/spotbugs/issues/1843") |
62 | 68 | @Override |
63 | 69 | public void buildEnvVars(EnvVars env) { |
64 | | - FilePath batchExecutablePath = new FilePath (Jenkins.get().getChannel(), getHome()); |
65 | 70 | String pathToExecutable = getHome() + "/bin"; |
66 | | - if( batchExecutablePath.getParent () != null ){ |
67 | | - env.put ("PATH+matlab_batch", batchExecutablePath.getParent().getRemote()); |
68 | | - } |
69 | 71 | env.put("PATH+matlabroot", pathToExecutable); |
| 72 | + Jenkins jenkinsInstance = Jenkins.getInstanceOrNull(); |
| 73 | + if(jenkinsInstance != null){ |
| 74 | + if(jenkinsInstance.getChannel() != null){ |
| 75 | + FilePath batchExecutablePath = new FilePath(jenkinsInstance.getChannel (), getHome()); |
| 76 | + if( batchExecutablePath.getParent() != null ){ |
| 77 | + env.put ("PATH+matlab_batch", batchExecutablePath.getParent().getRemote()); |
| 78 | + } |
| 79 | + } |
| 80 | + } |
70 | 81 | } |
71 | 82 |
|
72 | 83 | public static MatlabInstallation[] getAll () { |
|
0 commit comments