Skip to content

Commit

Permalink
Migrate from EE 8 to EE 9 (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Jan 17, 2025
1 parent 212bc99 commit 91adcc2
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 35 deletions.
17 changes: 1 addition & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>5.4</version>
<version>5.5</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -69,7 +69,6 @@
<groupId>hudson.queueSorter</groupId>
<artifactId>PrioritySorter</artifactId>
<version>1.3</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -79,12 +78,10 @@
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>jakarta-activation-api</artifactId>
<version>2.1.3-1</version>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>jakarta-mail-api</artifactId>
<version>2.1.3-1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
Expand All @@ -103,7 +100,6 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>build-timeout</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
Expand Down Expand Up @@ -179,7 +175,6 @@
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>python</artifactId>
<version>1.3</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -193,7 +188,6 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>timestamper</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -220,15 +214,6 @@
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>jython</artifactId>
<version>1.9</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<!-- satisfy upper bounds dependency error -->
<artifactId>commons-net</artifactId>
<version>3.11.1</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
</dependencies>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/configurationslicing/BooleanSlice.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.Map;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

public class BooleanSlice<I> extends Slice {
private Map<String, Boolean> nameToValue;
Expand Down Expand Up @@ -62,7 +62,7 @@ public List<I> getConfiguredItems() {
}

@Override
public Slice newInstance(StaplerRequest req, JSONObject formData) throws FormException {
public Slice newInstance(StaplerRequest2 req, JSONObject formData) throws FormException {
return new BooleanSlice<I>(
BooleanSlice.this.spec, req.bindJSONToList(ItemState.class, formData.get("itemstate")));
}
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/configurationslicing/ConfigurationSlicing.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
import hudson.model.View;
import hudson.model.ViewGroup;
import hudson.security.Permission;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.StaplerResponse2;
import org.kohsuke.stapler.interceptor.RequirePOST;

@Extension
Expand Down Expand Up @@ -103,7 +103,7 @@ private void addViews(String baseName, Collection<View> views, List<String> name
}
}

public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) {
public Object getDynamic(String token, StaplerRequest2 req, StaplerResponse2 rsp) {
Jenkins.get().checkPermission(Hudson.ADMINISTER);

for (Slicer s : getAxes()) {
Expand Down Expand Up @@ -188,7 +188,8 @@ public List<I> getWorklist() {
}

@RequirePOST
public void doSliceconfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
public void doSliceconfigSubmit(StaplerRequest2 req, StaplerResponse2 rsp)
throws IOException, ServletException {
String pathInfo = req.getPathInfo();
try {
T newslice = (T) slice.newInstance(req, req.getSubmittedForm());
Expand All @@ -212,7 +213,7 @@ private String getRedirectPath(String pathInfo) {
}
}

public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) {
public Object getDynamic(String token, StaplerRequest2 req, StaplerResponse2 rsp) {
Jenkins.get().checkPermission(Hudson.ADMINISTER);
String viewName = req.getParameter("view");
View view = null;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/configurationslicing/ParametersStringSlice.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.List;
import java.util.logging.Logger;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

public class ParametersStringSlice<I> extends UnorderedStringSlice<I> {

Expand All @@ -24,7 +24,7 @@ public UnorderedStringSlice<I> getInitialAccumulator() {
}

@Override
public Slice newInstance(StaplerRequest req, JSONObject formData) throws FormException {
public Slice newInstance(StaplerRequest2 req, JSONObject formData) throws FormException {
/*
{"itemNames":
["MD\n","Secure-A-1\nSecure-A-2\nSecure-B-1\nSecure-B-2\n",""],
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/configurationslicing/Slice.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import hudson.model.Descriptor.FormException;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

public abstract class Slice {
public abstract Slice newInstance(StaplerRequest req, JSONObject formData) throws FormException;
public abstract Slice newInstance(StaplerRequest2 req, JSONObject formData) throws FormException;
}
4 changes: 2 additions & 2 deletions src/main/java/configurationslicing/UnorderedStringSlice.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.logging.Logger;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

public class UnorderedStringSlice<I> extends Slice {

Expand Down Expand Up @@ -162,7 +162,7 @@ public List<String> getItemNames(String configurationString) {
}

@Override
public Slice newInstance(StaplerRequest req, JSONObject formData) throws FormException {
public Slice newInstance(StaplerRequest2 req, JSONObject formData) throws FormException {
return new UnorderedStringSlice<I>(
UnorderedStringSlice.this.spec,
getStringList(formData, "configValue"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.List;
import net.sf.json.JSONObject;
import org.jvnet.hudson.plugins.Jython;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

/**
* Slicer for the jython builder
Expand Down Expand Up @@ -40,10 +40,14 @@ public String getUrl() {
@Override
public Jython createBuilder(String command, List<Jython> existingBuilders, Jython oldBuilder) {
// this is an unfortunate workaround that is necessary due to the Jython constructor being private
StaplerRequest req = null;
StaplerRequest2 req = null;
JSONObject formData = new JSONObject();
formData.put("jython", command);
return (Jython) JYTHON_DESCRIPTOR.newInstance(req, formData);
try {
return (Jython) JYTHON_DESCRIPTOR.newInstance(req, formData);
} catch (Descriptor.FormException e) {
throw new RuntimeException(e);

Check warning on line 49 in src/main/java/configurationslicing/executeshell/ExecuteJythonSlicer.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 43-49 are not covered by tests
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.lang.reflect.Modifier;
import java.util.List;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

/**
* Slicer for the python builder
Expand Down Expand Up @@ -59,7 +59,7 @@ public Python createBuilder(String command, List<Python> existingBuilders, Pytho
if (python == null) {
// this is an unfortunate workaround that is necessary due to the Python constructor being private in
// certain versions
StaplerRequest req = null;
StaplerRequest2 req = null;

Check warning on line 62 in src/main/java/configurationslicing/executeshell/ExecutePythonSlicer.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 62 is not covered by tests
JSONObject formData = new JSONObject();
formData.put("python", command);
try {
Expand Down

0 comments on commit 91adcc2

Please sign in to comment.