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 #635

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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;
Copy link
Contributor

@rantoniuk rantoniuk Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the times of having 2 at the end of things is long gone 😆 No, let me rephrase - I expect those times to be long gone :-)

How about moving this class to org.kohsuke.stapler.ee9.StaplerRequest?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shipped in Jenkins core months ago and is now part of the public API which cannot be changed.


/**
* When a build fails it creates jira issues.
Expand Down Expand Up @@ -520,7 +520,7 @@ public ListBoxModel doFillTypeIdItems(@AncestorInPath final Item item) {
}

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

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/jira/JiraIssueMigrator.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import hudson.tasks.Publisher;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

public class JiraIssueMigrator extends Notifier {

Expand Down Expand Up @@ -146,7 +146,7 @@ public DescriptorImpl() {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

/**
* Resolve user email by searching his userId as username in Jira.
Expand All @@ -35,7 +35,7 @@ public String findMailAddressFor(User u) {

Job<?, ?> job = null;

StaplerRequest req = Stapler.getCurrentRequest();
StaplerRequest2 req = Stapler.getCurrentRequest2();
if (req != null) {
job = req.findAncestorObject(Job.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import hudson.tasks.Publisher;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

/**
* Task which releases the jira version specified in the parameters when the build completes.
Expand Down Expand Up @@ -91,7 +91,7 @@ public DescriptorImpl() {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import jenkins.tasks.SimpleBuildStep;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

/**
* Created by Reda on 18/12/2014.
Expand Down Expand Up @@ -96,7 +96,7 @@ public String getHelpFile() {
}

@Override
public JiraReleaseVersionUpdaterBuilder newInstance(StaplerRequest req, JSONObject formData)
public JiraReleaseVersionUpdaterBuilder newInstance(StaplerRequest2 req, JSONObject formData)
throws FormException {
return req.bindJSON(JiraReleaseVersionUpdaterBuilder.class, formData);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/jira/JiraSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import hudson.util.Secret;
import jakarta.servlet.ServletException;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
Expand Down Expand Up @@ -76,7 +77,6 @@
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.annotation.PreDestroy;
import javax.servlet.ServletException;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/jira/JiraVersionCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import hudson.tasks.Publisher;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

/**
* A build step which creates new Jira version
Expand Down Expand Up @@ -77,7 +77,7 @@ public boolean isApplicable(Class<? extends AbstractProject> jobType) {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import jenkins.tasks.SimpleBuildStep;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

/**
* A build step which creates new Jira version. It has the same functionality as
Expand Down Expand Up @@ -78,7 +78,7 @@ public boolean isApplicable(Class<? extends AbstractProject> jobType) {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

public class JiraIssueParameterDefinition extends ParameterDefinition {
private static final long serialVersionUID = 3927562542249244416L;
Expand All @@ -50,7 +50,7 @@ public JiraIssueParameterDefinition(String name, String description, String jira
}

@Override
public ParameterValue createValue(StaplerRequest req) {
public ParameterValue createValue(StaplerRequest2 req) {
String[] values = req.getParameterValues(getName());
if (values == null || values.length != 1) {
return null;
Expand All @@ -60,7 +60,7 @@ public ParameterValue createValue(StaplerRequest req) {
}

@Override
public ParameterValue createValue(StaplerRequest req, JSONObject formData) {
public ParameterValue createValue(StaplerRequest2 req, JSONObject formData) {
JiraIssueParameterValue value = req.bindJSON(JiraIssueParameterValue.class, formData);
return value;
}
Expand All @@ -71,7 +71,7 @@ public ParameterValue createValue(CLICommand command, String value) throws IOExc
}

public List<JiraIssueParameterDefinition.Result> getIssues() throws IOException, TimeoutException {
Job<?, ?> job = Stapler.getCurrentRequest().findAncestorObject(Job.class);
Job<?, ?> job = Stapler.getCurrentRequest2().findAncestorObject(Job.class);

JiraSite site = JiraSite.get(job);
if (site == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Builder;
import hudson.util.FormValidation;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import javax.servlet.ServletException;
import jenkins.tasks.SimpleBuildStep;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

public class JiraVersionParameterDefinition extends ParameterDefinition {
private static final long serialVersionUID = 4232979892748310160L;
Expand All @@ -41,7 +41,7 @@ public JiraVersionParameterDefinition(
}

@Override
public ParameterValue createValue(StaplerRequest req) {
public ParameterValue createValue(StaplerRequest2 req) {
String[] values = req.getParameterValues(getName());
if (values == null || values.length != 1) {
return null;
Expand All @@ -50,7 +50,7 @@ public ParameterValue createValue(StaplerRequest req) {
}

@Override
public ParameterValue createValue(StaplerRequest req, JSONObject formData) {
public ParameterValue createValue(StaplerRequest2 req, JSONObject formData) {
JiraVersionParameterValue value = req.bindJSON(JiraVersionParameterValue.class, formData);
return value;
}
Expand All @@ -61,7 +61,7 @@ public ParameterValue createValue(CLICommand command, String value) throws IOExc
}

public List<JiraVersionParameterDefinition.Result> getVersions() throws IOException {
Job<?, ?> contextJob = Stapler.getCurrentRequest().findAncestorObject(Job.class);
Job<?, ?> contextJob = Stapler.getCurrentRequest2().findAncestorObject(Job.class);

JiraSite site = JiraSite.get(contextJob);
if (site == null) {
Expand Down
Loading