Skip to content

Require Jenkins 2.479.1 and Jakarta EE 9 #6

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

Open
wants to merge 1 commit 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
12 changes: 11 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
buildPlugin(jdkVersions: [11])
/*
See the documentation for more options:
https://github.com/jenkins-infra/pipeline-library/
*/
buildPlugin(
forkCount: '1C', // run this number of tests in parallel for faster feedback. If the number terminates with a 'C', the value will be multiplied by the number of available CPU cores
useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests
configurations: [
[platform: 'linux', jdk: 21],
[platform: 'windows', jdk: 17],
])
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ trigger:
steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '11'
versionSpec: '17'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'

Expand All @@ -34,4 +34,4 @@ steps:
codeCoverageToolOption: 'JaCoCo'
goals: 'verify'
displayName: 'Build $(imageName)'

22 changes: 12 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.75</version>
<version>5.7</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -56,16 +56,16 @@
<changelist>999999-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/matlab-plugin</gitHubRepo>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.387</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<jenkins.baseline>2.479</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-${jenkins.baseline}.x</artifactId>
<version>2543.vfb_1a_5fb_9496d</version>
<version>4136.vca_c3202a_7fd1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -78,6 +78,12 @@
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Pipeline Step dependencies -->
<dependency>
Expand Down Expand Up @@ -116,22 +122,18 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>11.0.24</version>
<!-- must match version from core -->
<version>12.0.16</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<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>
<groupId>com.googlecode.maven-download-plugin</groupId>
Expand Down
43 changes: 15 additions & 28 deletions src/main/java/com/mathworks/ci/BuildArtifactAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
Expand All @@ -27,7 +28,7 @@ public class BuildArtifactAction implements Action {
private int totalCount;
private int skipCount;
private int failCount;
private String actionID;
private final String actionID;
private static final String ROOT_ELEMENT = "taskDetails";

public BuildArtifactAction(Run<?, ?> build, String actionID) {
Expand All @@ -37,9 +38,7 @@ public BuildArtifactAction(Run<?, ?> build, String actionID) {
// Setting the counts of task when Action is created.
try {
setCounts();
} catch (ParseException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
} catch (ParseException | InterruptedException e) {
throw new RuntimeException(e);
}
}
Expand Down Expand Up @@ -67,7 +66,7 @@ public String getUrlName() {
}

public List<BuildArtifactData> getBuildArtifact() throws ParseException, InterruptedException, IOException {
List<BuildArtifactData> artifactData = new ArrayList<BuildArtifactData>();
List<BuildArtifactData> artifactData = new ArrayList<>();
FilePath fl;
if (this.actionID == null) {
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
Expand All @@ -76,11 +75,10 @@ public List<BuildArtifactData> getBuildArtifact() throws ParseException, Interru
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
MatlabBuilderConstants.BUILD_ARTIFACT + this.actionID + ".json"));
}
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), "UTF-8")) {
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), StandardCharsets.UTF_8)) {
Object obj = new JSONParser().parse(reader);
JSONObject jo = (JSONObject) obj;
if (jo.get(ROOT_ELEMENT) instanceof JSONArray) {
JSONArray ja = (JSONArray) jo.get(ROOT_ELEMENT);
if (jo.get(ROOT_ELEMENT) instanceof JSONArray ja) {
Iterator itr2 = ja.iterator();
Iterator<Entry> itr1;
while (itr2.hasNext()) {
Expand Down Expand Up @@ -144,7 +142,7 @@ public void setOwner(Run owner) {
}

private void setCounts() throws InterruptedException, ParseException {
List<BuildArtifactData> artifactData = new ArrayList<BuildArtifactData>();
List<BuildArtifactData> artifactData = new ArrayList<>();
FilePath fl;
if (this.actionID == null) {
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
Expand All @@ -153,13 +151,12 @@ private void setCounts() throws InterruptedException, ParseException {
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
MatlabBuilderConstants.BUILD_ARTIFACT + this.actionID + ".json"));
}
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), "UTF-8")) {
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), StandardCharsets.UTF_8)) {
Object obj = new JSONParser().parse(reader);
JSONObject jo = (JSONObject) obj;

// getting taskDetails
if (jo.get(ROOT_ELEMENT) instanceof JSONArray) {
JSONArray ja = (JSONArray) jo.get(ROOT_ELEMENT);
if (jo.get(ROOT_ELEMENT) instanceof JSONArray ja) {
Iterator itr2 = ja.iterator();
Iterator<Entry> itr1;
while (itr2.hasNext()) {
Expand Down Expand Up @@ -223,22 +220,12 @@ private void iterateAllTaskAttributes(Entry pair, BuildArtifactData data) {
break;
case "skipReason":
String skipReasonKey = pair.getValue().toString();
String skipReason;
switch (skipReasonKey) {
case "UpToDate":
skipReason = "up-to-date";
break;
case "UserSpecified":
case "UserRequested":
skipReason = "user requested";
break;
case "DependencyFailed":
skipReason = "dependency failed";
break;
default:
skipReason = skipReasonKey;
break;
}
String skipReason = switch (skipReasonKey) {
case "UpToDate" -> "up-to-date";
case "UserSpecified", "UserRequested" -> "user requested";
case "DependencyFailed" -> "dependency failed";
default -> skipReasonKey;
};
data.setSkipReason(skipReason);
break;
default:
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/mathworks/ci/BuildConsoleAnnotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serial;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
Expand Down Expand Up @@ -67,10 +68,12 @@ public void close() throws IOException {
}

private static class ConsoleLogFilterImpl extends ConsoleLogFilter implements Serializable {
@Serial
private static final long serialVersionUID = 1;
private byte[][] buildNotes = createBuildNotes();

// Taking care of old MATLAB build actions.
@Serial
private Object readResolve() {
if (buildNotes == null) {
buildNotes = createBuildNotes();
Expand All @@ -79,7 +82,7 @@ private Object readResolve() {
}

@Override
public OutputStream decorateLogger(Run build, OutputStream logger) throws IOException, InterruptedException {
public OutputStream decorateLogger(Run build, OutputStream logger) {
return new BuildConsoleAnnotator(logger, Charsets.UTF_8, buildNotes);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/mathworks/ci/BuildTargetNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import com.google.common.annotations.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.MarkupText;
import hudson.console.ConsoleAnnotationDescriptor;
Expand All @@ -31,6 +32,8 @@ public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {

@Extension
public static final class DescriptorImpl extends ConsoleAnnotationDescriptor {
@NonNull
@Override
public String getDisplayName() {
return "Build targets";
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/mathworks/ci/FormValidationUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Copyright 2019-2024 The MathWorks, Inc.
*
* <p>
* This is Utility class which provides commonly used methods for form validations across builders
*/

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/mathworks/ci/ListenerLogDecorator.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import hudson.console.LineTransformationOutputStream;
import hudson.model.TaskListener;

public class ListenerLogDecorator extends LineTransformationOutputStream {
private OutputStream listener;
private final Charset charsetUtf8 = Charset.forName("UTF-8");
private final OutputStream listener;
private final Charset charsetUtf8 = StandardCharsets.UTF_8;

public ListenerLogDecorator(TaskListener listner) throws IOException {
public ListenerLogDecorator(TaskListener listner) {
this.listener = listner != null ? listner.getLogger() : null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Copyright 2020-2024 The MathWorks, Inc.
*
* <p>
* Class to parse Stapler request for Use MATLAB Version build wrapper.
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class MatlabBuilderConstants {
public static final String TASK_RUN_PROGRESS_PLUGIN = "+ciplugins/+jenkins/TaskRunProgressPlugin.m";
public static final String BUILD_ARTIFACT = "buildArtifact";

public static final String NEW_LINE = System.getProperty("line.separator");
public static final String NEW_LINE = System.lineSeparator();

// MATLAB Runner Script
public static final String TEST_RUNNER_SCRIPT = String.join(NEW_LINE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* Copyright 2021-2024 The MathWorks, Inc.
*/

import java.lang.Exception;

public class MatlabExecutionException extends Exception {

private final int exitCode;
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/com/mathworks/ci/MatlabInstallation.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

/**
* Copyright 2020-2024 The MathWorks, Inc.
*
* <p>
* Describable class for adding MATLAB installations in Jenkins Global Tool configuration.
*/

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.CopyOnWrite;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
import hudson.Util;
import hudson.model.EnvironmentSpecific;
import hudson.model.Node;
Expand All @@ -18,8 +18,9 @@
import hudson.tools.ToolDescriptor;
import hudson.tools.ToolInstallation;
import hudson.tools.ToolProperty;
import java.io.File;

import java.io.IOException;
import java.io.Serial;
import java.util.Arrays;
import java.util.List;
import javax.annotation.CheckForNull;
Expand All @@ -29,10 +30,11 @@
import net.sf.json.JSONObject;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

public class MatlabInstallation extends ToolInstallation
implements EnvironmentSpecific<MatlabInstallation>, NodeSpecific<MatlabInstallation> {
@Serial
private static final long serialVersionUID = 1L;

@DataBoundConstructor
Expand Down Expand Up @@ -94,6 +96,7 @@ public DescriptorImpl() {
load();
}

@NonNull
@Override
public String getDisplayName() {
return "MATLAB";
Expand All @@ -105,7 +108,7 @@ public MatlabInstallation[] getInstallations() {
}

@Override
public MatlabInstallation newInstance(StaplerRequest req, JSONObject formData) {
public MatlabInstallation newInstance(StaplerRequest2 req, @NonNull JSONObject formData) {
return (MatlabInstallation) req.bindJSON(clazz, formData);
}

Expand Down
Loading