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

Migrate from EE 8 to EE 9 #300

Merged
merged 1 commit into from
Feb 11, 2025
Merged
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
8 changes: 4 additions & 4 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.88</version>
<version>5.7</version>
<relativePath />
</parent>

Expand All @@ -18,8 +18,8 @@
<properties>
<changelist>999999-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<jenkins.baseline>2.440</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<jenkins.baseline>2.479</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
<spotbugs.effort>Max</spotbugs.effort>
<hpi.compatibleSinceVersion>4.0</hpi.compatibleSinceVersion>
</properties>
Expand Down Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-${jenkins.baseline}.x</artifactId>
<version>3435.v238d66a_043fb_</version>
<version>3893.v213a_42768d35</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import hudson.Extension;
import jenkins.model.GlobalConfiguration;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

/**
* Global Jenkins configuration for Promoted Builds
Expand Down Expand Up @@ -33,7 +33,7 @@ public GlobalBuildPromotedBuilds() {
}

@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
public boolean configure(StaplerRequest2 req, JSONObject json) throws FormException {
req.bindJSON(this, json);
save();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import hudson.Extension;
import hudson.Util;
Expand Down Expand Up @@ -94,7 +94,7 @@ public JobPropertyImpl(Set<String> activeProcessNames) {
this.activeProcessNames.addAll(activeProcessNames);
}

private JobPropertyImpl(StaplerRequest req, JSONObject json) throws Descriptor.FormException, IOException {
private JobPropertyImpl(StaplerRequest2 req, JSONObject json) throws Descriptor.FormException, IOException {
// a hack to get the owning AbstractProject.
// this is needed here so that we can load items
List<Ancestor> ancs = req.getAncestors();
Expand Down Expand Up @@ -416,7 +416,7 @@ public boolean isApplicable(Class<? extends Job> jobType) {
}

@Override
public JobPropertyImpl newInstance(StaplerRequest req, JSONObject json) throws Descriptor.FormException {
public JobPropertyImpl newInstance(StaplerRequest2 req, JSONObject json) throws Descriptor.FormException {
try {
if(json.has("promotions"))
return new JobPropertyImpl(req, json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.HttpResponses;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.StaplerResponse2;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -218,7 +218,7 @@ private Object readResolve() {
/**
* Binds {@link Status} to URL hierarchy by its name.
*/
public Status getDynamic(String name, StaplerRequest req, StaplerResponse rsp) {
public Status getDynamic(String name, StaplerRequest2 req, StaplerResponse2 rsp) {
return getPromotion(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.HttpResponses;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
import org.kohsuke.stapler.interceptor.RequirePOST;
Expand Down Expand Up @@ -132,7 +132,7 @@ public List<Permalink> getPermalinks() {
}

@RequirePOST
public HttpResponse doCreateProcess(@QueryParameter String name, StaplerRequest req) throws IOException {
public HttpResponse doCreateProcess(@QueryParameter String name, StaplerRequest2 req) throws IOException {
property.createProcessFromXml(name, req.getInputStream());
return HttpResponses.ok();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/hudson/plugins/promoted_builds/Promotion.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.HttpResponses;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.StaplerResponse2;

import hudson.init.InitMilestone;
import hudson.init.Initializer;
Expand Down Expand Up @@ -306,7 +306,7 @@ public List<ParameterDefinition> getParameterDefinitionsWithValue(){
return definitions;
}

public void doRebuild(StaplerRequest req, StaplerResponse rsp) throws IOException {
public void doRebuild(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException {
throw HttpResponses.error(404, "Promotions may not be rebuilt directly");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
import net.sf.json.JSONObject;
import org.kohsuke.stapler.HttpResponses;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.StaplerResponse2;

import javax.servlet.ServletException;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -118,7 +118,7 @@ public final class PromotionProcess extends AbstractProject<PromotionProcess,Pro
* @throws IOException {@link PromotionProcess} creation issue
* @return Parsed promotion process
*/
public static PromotionProcess fromJson(StaplerRequest req, JSONObject o) throws FormException, IOException {
public static PromotionProcess fromJson(StaplerRequest2 req, JSONObject o) throws FormException, IOException {
String name = o.getString("name");
try {
Jenkins.checkGoodName(name);
Expand All @@ -140,7 +140,7 @@ public void doSetName(String name) {
super.doSetName(name);
}

/*package*/ void configure(StaplerRequest req, JSONObject c) throws Descriptor.FormException, IOException {
/*package*/ void configure(StaplerRequest2 req, JSONObject c) throws Descriptor.FormException, IOException {
// apply configuration
conditions.rebuild(req,c.optJSONObject("conditions"), PromotionCondition.all());

Expand Down Expand Up @@ -553,7 +553,7 @@ public Future<Promotion> scheduleBuild2(@NonNull AbstractBuild<?,?> build,


@Override
public void doBuild(StaplerRequest req, StaplerResponse rsp, @QueryParameter TimeDuration delay) throws IOException, ServletException {
public void doBuild(StaplerRequest2 req, StaplerResponse2 rsp, @QueryParameter TimeDuration delay) throws IOException, ServletException {
throw HttpResponses.error(404, "Promotion processes may not be built directly");
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/hudson/plugins/promoted_builds/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import net.sf.json.JSONNull;
import net.sf.json.JSONObject;

import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.StaplerResponse2;

import javax.servlet.ServletException;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -386,7 +386,7 @@ public boolean canBuild() {
* @throws ServletException Request handling error
*/
@POST
public void doBuild(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
public void doBuild(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException, ServletException {

final PromotionProcess process = getProcess();
if (process == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.acegisecurity.context.SecurityContextHolder;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -209,7 +209,7 @@ public String getDisplayName() {
return Messages.DownstreamPassCondition_DisplayName();
}

public PromotionCondition newInstance(StaplerRequest req, JSONObject formData) throws FormException {
public PromotionCondition newInstance(StaplerRequest2 req, JSONObject formData) throws FormException {
return new DownstreamPassCondition(
formData.getString("jobs"), formData.getBoolean("evenIfUnstable"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;

import javax.servlet.ServletException;
import jakarta.servlet.ServletException;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.acegisecurity.GrantedAuthority;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.StaplerResponse2;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.verb.POST;

Expand Down Expand Up @@ -194,7 +194,7 @@ public Future<Promotion> approve(AbstractBuild<?,?> build, PromotionProcess prom
* Web method to handle the approval action submitted by the user.
*/
@POST
public void doApprove(StaplerRequest req, StaplerResponse rsp,
public void doApprove(StaplerRequest2 req, StaplerResponse2 rsp,
@AncestorInPath PromotionProcess promotionProcess,
@AncestorInPath AbstractBuild<?,?> build) throws IOException, ServletException {

Expand Down Expand Up @@ -304,7 +304,7 @@ public String getDisplayName() {
}

@Override
public ManualCondition newInstance(StaplerRequest req, JSONObject formData) throws FormException {
public ManualCondition newInstance(StaplerRequest2 req, JSONObject formData) throws FormException {
ManualCondition instance = new ManualCondition();
instance.users = formData.getString("users");
instance.parameterDefinitions = Descriptor.newInstancesFromHeteroList(req, formData, "parameters", ParameterDefinition.all());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import hudson.plugins.promoted_builds.PromotionProcess;
import hudson.plugins.promoted_builds.Status;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -95,7 +95,7 @@ public String getDisplayName() {
return Messages.UpstreamPromotionCondition_DisplayName();
}

public PromotionCondition newInstance(StaplerRequest req, JSONObject formData) throws FormException {
public PromotionCondition newInstance(StaplerRequest2 req, JSONObject formData) throws FormException {
return new UpstreamPromotionCondition(
formData.getString("promotions"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.export.Exported;

/**
Expand Down Expand Up @@ -85,7 +85,7 @@ public PromotedBuildParameterDefinition(String name, String jobName, String proc
}

@Override
public PromotedBuildParameterValue createValue(StaplerRequest req, JSONObject jo) {
public PromotedBuildParameterValue createValue(StaplerRequest2 req, JSONObject jo) {
PromotedBuildParameterValue value = req.bindJSON(PromotedBuildParameterValue.class, jo);
value.setPromotionProcessName(promotionProcessName);
value.setDescription(getDescription());
Expand Down Expand Up @@ -136,15 +136,15 @@ public String getProcess() {
* Gets a list of promoted builds for the project.
* @return List of {@link AbstractBuild}s, which have been promoted
* @deprecated This method retrieves the base item for relative addressing from
* the {@link StaplerRequest}. The relative addressing may be malfunctional if
* you use this method outside {@link StaplerRequest}s.
* the {@link StaplerRequest2}. The relative addressing may be malfunctional if
* you use this method outside {@link StaplerRequest2}s.
* Use {@link #getRuns(hudson.model.Item)} instead
*/
@NonNull
@Deprecated
public List getBuilds() {
// Try to get ancestor from the object, otherwise pass null and disable the relative addressing
final StaplerRequest currentRequest = Stapler.getCurrentRequest();
final StaplerRequest2 currentRequest = Stapler.getCurrentRequest2();
final Item item = currentRequest != null ? currentRequest.findAncestorObject(Item.class) : null;
return getRuns(item);
}
Expand Down Expand Up @@ -202,7 +202,7 @@ public String getHelpFile() {
}

@Override
public ParameterDefinition newInstance(StaplerRequest req, JSONObject formData) throws FormException {
public ParameterDefinition newInstance(StaplerRequest2 req, JSONObject formData) throws FormException {
return req.bindJSON(PromotedBuildParameterDefinition.class, formData);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import hudson.plugins.promoted_builds.PromotionProcess;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

/**
* {@link RedeployPublisher} altered for batch task.
Expand All @@ -37,7 +37,7 @@ public boolean isApplicable(Class<? extends AbstractProject> jobType) {

@SuppressFBWarnings("NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE")
@Override
public RedeployPublisher newInstance(StaplerRequest req, JSONObject formData) throws FormException {
public RedeployPublisher newInstance(StaplerRequest2 req, JSONObject formData) throws FormException {
return req.bindJSON(RedeployBatchTaskPublisher.class,formData);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void testCaptureXml() throws Exception {
.accumulate("conditions",new JSONObject()
.accumulate("hudson-plugins-promoted_builds-conditions-SelfPromotionCondition",
new JSONObject().accumulate("evenIfUnstable", false)));
PromotionProcess p = PromotionProcess.fromJson(Stapler.getCurrentRequest(), o);
PromotionProcess p = PromotionProcess.fromJson(Stapler.getCurrentRequest2(), o);
assertEquals("foo", p.getName());
assertEquals("star-gold", p.getIcon());
assertEquals(1, p.conditions.size());
Expand Down