Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.16.0 snapshot qualification #388

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -9,7 +11,7 @@
</parent>

<artifactId>matlab</artifactId>
<version>2.15.1-SNAPSHOT</version>
<version>2.16.0-SNAPSHOT</version>
<packaging>hpi</packaging>

<name>MATLAB Plugin</name>
Expand Down Expand Up @@ -56,8 +58,6 @@
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.387</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<!-- TODO fix violations -->
<spotbugs.threshold>High</spotbugs.threshold>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -132,8 +132,7 @@
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
</plugin>
<!-- Plugin to download the matlab run scripts and keep it under class
resource folder -->
<!-- Plugin to download the matlab run scripts and keep it under class resource folder -->
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
Expand All @@ -146,7 +145,8 @@
<goal>wget</goal>
</goals>
<configuration>
<url>https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command</url>
<url>
https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command</url>
<unpack>false</unpack>
<outputDirectory>${basedir}/src/main/resources/glnxa64</outputDirectory>
<skipCache>true</skipCache>
Expand All @@ -160,7 +160,8 @@
<goal>wget</goal>
</goals>
<configuration>
<url>https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/maci64/run-matlab-command</url>
<url>
https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/maci64/run-matlab-command</url>
<unpack>false</unpack>
<outputDirectory>${basedir}/src/main/resources/maci64</outputDirectory>
<skipCache>true</skipCache>
Expand All @@ -174,7 +175,8 @@
<goal>wget</goal>
</goals>
<configuration>
<url>https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/maca64/run-matlab-command</url>
<url>
https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/maca64/run-matlab-command</url>
<unpack>false</unpack>
<outputDirectory>${basedir}/src/main/resources/maca64</outputDirectory>
<skipCache>true</skipCache>
Expand All @@ -188,7 +190,8 @@
<goal>wget</goal>
</goals>
<configuration>
<url>https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/win64/run-matlab-command.exe</url>
<url>
https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/win64/run-matlab-command.exe</url>
<unpack>false</unpack>
<outputDirectory>${basedir}/src/main/resources/win64</outputDirectory>
<skipCache>true</skipCache>
Expand All @@ -202,7 +205,8 @@
<goal>wget</goal>
</goals>
<configuration>
<url>https://ssd.mathworks.com/supportfiles/ci/matlab-script-generator/v0/matlab-script-generator.zip</url>
<url>
https://ssd.mathworks.com/supportfiles/ci/matlab-script-generator/v0/matlab-script-generator.zip</url>
<unpack>false</unpack>
<outputDirectory>${basedir}/src/main/resources</outputDirectory>
<skipCache>true</skipCache>
Expand All @@ -214,8 +218,8 @@
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<!-- This plugin's configuration is used to store Eclipse m2e settings only. It has
no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/mathworks/ci/BuildTargetNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import com.google.common.annotations.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.MarkupText;
import hudson.console.ConsoleAnnotationDescriptor;
Expand All @@ -15,7 +14,6 @@

public class BuildTargetNote extends ConsoleNote {
@VisibleForTesting
@SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "Visible for testing")
public static boolean ENABLED = !Boolean.getBoolean(BuildTargetNote.class.getName() + ".disabled");

public BuildTargetNote() {
Expand Down
21 changes: 4 additions & 17 deletions src/main/java/com/mathworks/ci/MatlabInstallation.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Describable class for adding MATLAB installations in Jenkins Global Tool configuration.
*/

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.CopyOnWrite;
import hudson.EnvVars;
import hudson.Extension;
Expand All @@ -15,15 +14,12 @@
import hudson.model.EnvironmentSpecific;
import hudson.model.Node;
import hudson.model.TaskListener;
import hudson.remoting.VirtualChannel;
import hudson.slaves.NodeSpecific;
import hudson.tools.ToolDescriptor;
import hudson.tools.ToolInstallation;
import hudson.tools.ToolProperty;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import javax.annotation.CheckForNull;
Expand Down Expand Up @@ -62,22 +58,13 @@ public MatlabInstallation forNode(@Nonnull Node node, TaskListener log) throws I
return new MatlabInstallation(getName(), translateFor(node, log), getProperties().toList());
}

@SuppressFBWarnings(value = {
"NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" }, justification = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE: Its false positive scenario for sport bug which is fixed in later versions "
+ "https://github.com/spotbugs/spotbugs/issues/1843")
@Override
public void buildEnvVars(EnvVars env) {
String pathToExecutable = getHome() + "/bin";
env.put("PATH+matlabroot", pathToExecutable);
Jenkins jenkinsInstance = Jenkins.getInstanceOrNull();
if (jenkinsInstance != null) {
if (jenkinsInstance.getChannel() != null) {
FilePath batchExecutablePath = new FilePath(jenkinsInstance.getChannel(), getHome());
if (batchExecutablePath.getParent() != null) {
env.put("PATH+matlab_batch", batchExecutablePath.getParent().getRemote());
}
}
String home = getHome();
if (home == null) {
return;
}
env.put("PATH+matlabroot", home + "/bin");
}

public static MatlabInstallation[] getAll() {
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/com/mathworks/ci/MatlabReleaseInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.lang.InterruptedException;
import java.nio.charset.StandardCharsets;
import java.nio.file.NotDirectoryException;
import java.util.HashMap;
Expand All @@ -25,7 +27,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.xml.sax.SAXException;
import hudson.FilePath;

public class MatlabReleaseInfo {
Expand Down Expand Up @@ -74,11 +76,6 @@ public boolean verLessThan(double version) throws MatlabVersionNotFoundException
}
}

@SuppressFBWarnings(value = { "REC_CATCH_EXCEPTION",
"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" }, justification = "REC_CATCH_EXCEPTION: Irrespective of exception type, intention is to handle it in same way."
+
" Also, there is no intention to propagate any runtime exception up in the hierarchy." +
"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE: This is a false positive reported by spotbugs for JDK 11 for try-with-resources block.")
private Map<String, String> getVersionInfoFromFile() throws MatlabVersionNotFoundException {
if (MapUtils.isEmpty(versionInfoCache)) {
try {
Expand Down Expand Up @@ -139,7 +136,7 @@ private Map<String, String> getVersionInfoFromFile() throws MatlabVersionNotFoun
// Update the versionInfoCache with actual version extracted from Contents.m
versionInfoCache.put(VERSION_TAG, actualVersion);
}
} catch (Exception e) {
} catch (InterruptedException | IOException | ParserConfigurationException | SAXException e) {
throw new MatlabVersionNotFoundException(
Message.getValue("Releaseinfo.matlab.version.not.found.error"), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ public class MatlabVersionNotFoundException extends Exception {
MatlabVersionNotFoundException(String errorMessage, Throwable err) {
super(errorMessage, err);
}

MatlabVersionNotFoundException(String errorMessage) {
super(errorMessage);
}
}
26 changes: 5 additions & 21 deletions src/main/java/com/mathworks/ci/UseMatlabVersionBuildWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,39 +197,23 @@ public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher
if (!matlabExecutablePath.exists()) {
throw new MatlabNotFoundError(Message.getValue("matlab.not.found.error"));
}
// Add matlab-batch executable in path
FilePath batchExecutable = getNthParentFilePath(matlabExecutablePath, 3);
if (batchExecutable != null && batchExecutable.exists()) {
context.env("PATH+matlab_batch", batchExecutable.getRemote());
FilePath matlabBinDir = matlabExecutablePath.getParent();
if (matlabBinDir == null) {
throw new MatlabNotFoundError(Message.getValue("matlab.not.found.error"));
}

// Add "matlabroot" without bin as env variable which will be available across
// the build.
context.env("matlabroot", nodeSpecificMatlab);
// Add matlab bin to path to invoke MATLAB directly on command line.
context.env("PATH+matlabroot", matlabExecutablePath.getParent().getRemote());
context.env("PATH+matlabroot", matlabBinDir.getRemote());
;
listener.getLogger().println("\n" + String.format(Message.getValue("matlab.added.to.path.from"),
matlabExecutablePath.getParent().getRemote()) + "\n");
matlabBinDir.getRemote()) + "\n");
}

private String getNodeSpecificExecutable(Launcher launcher) {
return (launcher.isUnix()) ? "/bin/matlab" : "\\bin\\matlab.exe";
}

public static FilePath getNthParentFilePath(FilePath path, int levels) {
if (path == null || levels < 0) {
return null;
}

FilePath currentPath = path;
for (int i = 0; i < levels; i++) {
if (currentPath == null) {
return null;
}
currentPath = currentPath.getParent();
}
return currentPath;
}

}
14 changes: 4 additions & 10 deletions src/main/java/com/mathworks/ci/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,14 @@ public static void addMatlabToEnvPathFromAxis(Computer cmp, TaskListener listene
return;
}

FilePath matlabRoot = getNodeSpecificHome(name,
cmp.getNode(), listener, env);
FilePath matlabRoot = getNodeSpecificHome(name, cmp.getNode(), listener, env);

if (matlabRoot != null && matlabRoot.getParent().exists()) {
env.put("PATH+matlab_batch", matlabRoot.getParent().getRemote());
}

String matlabExecutablePath = getNodeSpecificHome(name,
cmp.getNode(), listener, env).getRemote() + ((Boolean.TRUE.equals(cmp.isUnix())) ? "/bin" : "\\bin");
env.put("PATH+matlabroot", matlabExecutablePath);
FilePath matlabBin = new FilePath(matlabRoot, "bin");
env.put("PATH+matlabroot", matlabBin.getRemote());

// Specify which MATLAB was added to path.
listener.getLogger().println(
"\n" + String.format(Message.getValue("matlab.added.to.path.from"), matlabExecutablePath) + "\n");
"\n" + String.format(Message.getValue("matlab.added.to.path.from"), matlabBin.getRemote()) + "\n");
}

public static FilePath getNodeSpecificHome(String instName, Node node, TaskListener listener, EnvVars env)
Expand Down
Loading