Skip to content

Commit

Permalink
Require Jenkins 2.479 or newer (#1671)
Browse files Browse the repository at this point in the history
* Require Jenkins 2.479 or newer

Update to use Jakarta EE 9, StaplerRequest2, and StaplerResponse2

* Use scm API adapted for Jakarta EE 9

* Remove 2.462 from Jenkinsfile

Standard is better

* Update pom.xml

* Use released SCM API plugin

---------

Co-authored-by: Basil Crow <[email protected]>
  • Loading branch information
MarkEWaite and basil authored Oct 10, 2024
1 parent 4b59bed commit 436ae20
Show file tree
Hide file tree
Showing 36 changed files with 99 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ buildPlugin(
// we use Docker for containerized tests
useContainerAgent: false,
configurations: [
[platform: 'linux', jdk: 21, jenkins: '2.462'],
[platform: 'linux', jdk: 21],
[platform: 'windows', jdk: 17],
])
12 changes: 9 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.88</version>
<version>5.1</version>
<relativePath />
</parent>

<artifactId>git</artifactId>
<version>${revision}${changelist}</version>
<packaging>hpi</packaging>

<name>Git plugin</name>
<url>https://github.com/${gitHubRepo}</url>
<inceptionYear>2007</inceptionYear>
Expand Down Expand Up @@ -64,8 +65,11 @@
<revision>5.5.3</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<jenkins.baseline>2.440</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.462</jenkins.baseline>
<!-- TODO Replace with the standard jenkins.baseline references after LTS requires Java 17 -->
<!-- <jenkins.version>${jenkins.baseline}.1</jenkins.version> -->
<jenkins.version>2.479</jenkins.version>
<no-test-jar>false</no-test-jar>
<!-- Jenkins.MANAGE is still in Beta -->
<useBeta>true</useBeta>
Expand Down Expand Up @@ -114,6 +118,8 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<!-- TODO: Remove when release is available in plugin BOM -->
<version>698.v8e3b_c788f0a_6</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.interceptor.RequirePOST;

import java.io.Serializable;
Expand Down Expand Up @@ -58,7 +58,7 @@ public GlobalConfigurationCategory getCategory() {
}

@RequirePOST
public HttpResponse doGenerate(StaplerRequest req) {
public HttpResponse doGenerate(StaplerRequest2 req) {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);

String apiTokenName = req.getParameter("apiTokenName");
Expand Down Expand Up @@ -102,7 +102,7 @@ private static byte[] hashedBytes(byte[] tokenBytes) {
}

@RequirePOST
public HttpResponse doRevoke(StaplerRequest req) {
public HttpResponse doRevoke(StaplerRequest2 req) {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);

String apiTokenUuid = req.getParameter("apiTokenUuid");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/git/GitPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.jenkinsci.plugins.gitclient.UnsupportedCommand;
import org.kohsuke.stapler.*;

import javax.servlet.ServletException;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
Expand Down Expand Up @@ -437,7 +437,7 @@ public FormValidation doCheckNoteMsg(@QueryParameter String value) {
}

public FormValidation doCheckRemote(
@AncestorInPath AbstractProject project, StaplerRequest req)
@AncestorInPath AbstractProject project, StaplerRequest2 req)
throws IOException, ServletException {
String remote = req.getParameter("value");
boolean isMerge = req.getParameter("isMerge") != null;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/hudson/plugins/git/GitSCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.export.Exported;

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

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -1884,7 +1884,7 @@ public static PreBuildMergeOptions createMergeOptions(UserMergeOptions mergeOpti
return mergeOptions;
}

public FormValidation doGitRemoteNameCheck(StaplerRequest req)
public FormValidation doGitRemoteNameCheck(StaplerRequest2 req)
throws IOException, ServletException {
String mergeRemoteName = req.getParameter("value");
boolean isMerge = req.getParameter("isMerge") != null;
Expand All @@ -1905,7 +1905,7 @@ public FormValidation doGitRemoteNameCheck(StaplerRequest req)
}

@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
public boolean configure(StaplerRequest2 req, JSONObject formData) throws FormException {
req.bindJSON(this, formData);
save();
return true;
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/hudson/plugins/git/GitStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static javax.servlet.http.HttpServletResponse.SC_OK;
import static jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static jakarta.servlet.http.HttpServletResponse.SC_OK;
import jenkins.model.Jenkins;
import jenkins.model.ParameterizedJobMixIn;
import jenkins.scm.api.SCMEvent;
Expand Down Expand Up @@ -180,7 +180,7 @@ public HttpResponse doNotifyCommit(HttpServletRequest request, @QueryParameter(r

return new HttpResponse() {
@Override
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException {
public void generateResponse(StaplerRequest2 req, StaplerResponse2 rsp, Object node) throws IOException {
rsp.setStatus(SC_OK);
rsp.setContentType("text/plain");
for (int i = 0; i < contributors.size(); i++) {
Expand Down Expand Up @@ -232,7 +232,7 @@ public static class ResponseContributor {
* @param rsp the response.
* @since 1.4.1
*/
public void addHeaders(StaplerRequest req, StaplerResponse rsp) {
public void addHeaders(StaplerRequest2 req, StaplerResponse2 rsp) {
}

/**
Expand All @@ -243,7 +243,7 @@ public void addHeaders(StaplerRequest req, StaplerResponse rsp) {
* @param w the writer.
* @since 1.4.1
*/
public void writeBody(StaplerRequest req, StaplerResponse rsp, PrintWriter w) {
public void writeBody(StaplerRequest2 req, StaplerResponse2 rsp, PrintWriter w) {
writeBody(w);
}

Expand Down Expand Up @@ -543,7 +543,7 @@ public PollingScheduledResponseContributor(Item project) {
*/
@Override
@SuppressWarnings("deprecation")
public void addHeaders(StaplerRequest req, StaplerResponse rsp) {
public void addHeaders(StaplerRequest2 req, StaplerResponse2 rsp) {
// Calls a deprecated getAbsoluteUrl() method because this is a remote API case
// as described in the Javadoc of the deprecated getAbsoluteUrl() method.
rsp.addHeader("Triggered", project.getAbsoluteUrl());
Expand Down Expand Up @@ -578,7 +578,7 @@ public ScheduledResponseContributor(Item project) {
*/
@Override
@SuppressWarnings("deprecation")
public void addHeaders(StaplerRequest req, StaplerResponse rsp) {
public void addHeaders(StaplerRequest2 req, StaplerResponse2 rsp) {
// Calls a deprecated getAbsoluteUrl() method because this is a remote API case
// as described in the Javadoc of the deprecated getAbsoluteUrl() method.
rsp.addHeader("Triggered", project.getAbsoluteUrl());
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/hudson/plugins/git/GitStatusCrumbExclusion.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import hudson.Extension;
import hudson.security.csrf.CrumbExclusion;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/hudson/plugins/git/GitTagAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import jenkins.model.*;
import org.jenkinsci.plugins.gitclient.Git;
import org.jenkinsci.plugins.gitclient.GitClient;
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.export.ExportedBean;
import org.kohsuke.stapler.interceptor.RequirePOST;

import javax.servlet.ServletException;
import jakarta.servlet.ServletException;
import java.io.File;
import java.io.IOException;
import java.util.*;
Expand Down Expand Up @@ -149,7 +149,7 @@ public String getTooltip() {
* @throws ServletException on servlet error
*/
@RequirePOST
public synchronized void doSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
public synchronized void doSubmit(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException, ServletException {
getACL().checkPermission(getPermission());

try (MultipartFormDataParser parser = new MultipartFormDataParser(req)) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/hudson/plugins/git/browser/AssemblaWeb.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.interceptor.RequirePOST;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import javax.servlet.ServletException;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -98,7 +98,7 @@ public String getDisplayName() {
@Override
@SuppressFBWarnings(value = "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
justification = "Inherited javadoc commits that req is non-null")
public AssemblaWeb newInstance(StaplerRequest req, @NonNull JSONObject jsonObject) throws FormException {
public AssemblaWeb newInstance(StaplerRequest2 req, @NonNull JSONObject jsonObject) throws FormException {
return req.bindJSON(AssemblaWeb.class, jsonObject);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/git/browser/BitbucketServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.sf.json.JSONObject;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand Down Expand Up @@ -81,7 +81,7 @@ public String getDisplayName() {
@Override
@SuppressFBWarnings(value = "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
justification = "Inherited javadoc commits that req is non-null")
public BitbucketServer newInstance(StaplerRequest req, @NonNull JSONObject jsonObject) throws FormException {
public BitbucketServer newInstance(StaplerRequest2 req, @NonNull JSONObject jsonObject) throws FormException {
return req.bindJSON(BitbucketServer.class, jsonObject);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/git/browser/BitbucketWeb.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.sf.json.JSONObject;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand Down Expand Up @@ -82,7 +82,7 @@ public String getDisplayName() {
@Override
@SuppressFBWarnings(value = "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
justification = "Inherited javadoc commits that req is non-null")
public BitbucketWeb newInstance(StaplerRequest req, @NonNull JSONObject jsonObject) throws FormException {
public BitbucketWeb newInstance(StaplerRequest2 req, @NonNull JSONObject jsonObject) throws FormException {
return req.bindJSON(BitbucketWeb.class, jsonObject);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/git/browser/CGit.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import net.sf.json.JSONObject;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand Down Expand Up @@ -92,7 +92,7 @@ public String getDisplayName() {
@Override
@SuppressFBWarnings(value = "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
justification = "Inherited javadoc commits that req is non-null")
public CGit newInstance(StaplerRequest req, @NonNull JSONObject jsonObject) throws FormException {
public CGit newInstance(StaplerRequest2 req, @NonNull JSONObject jsonObject) throws FormException {
return req.bindJSON(CGit.class, jsonObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.interceptor.RequirePOST;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import javax.servlet.ServletException;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.net.URL;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -79,7 +79,7 @@ public String getDisplayName() {
@Override
@SuppressFBWarnings(value = "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
justification = "Inherited javadoc commits that req is non-null")
public FisheyeGitRepositoryBrowser newInstance(StaplerRequest req, @NonNull JSONObject jsonObject) throws FormException {
public FisheyeGitRepositoryBrowser newInstance(StaplerRequest2 req, @NonNull JSONObject jsonObject) throws FormException {
return req.bindJSON(FisheyeGitRepositoryBrowser.class, jsonObject);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.interceptor.RequirePOST;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import javax.servlet.ServletException;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
Expand Down Expand Up @@ -84,7 +84,7 @@ public String getDisplayName() {
@Override
@SuppressFBWarnings(value = "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
justification = "Inherited javadoc commits that req is non-null")
public GitBlitRepositoryBrowser newInstance(StaplerRequest req, @NonNull JSONObject jsonObject) throws FormException {
public GitBlitRepositoryBrowser newInstance(StaplerRequest2 req, @NonNull JSONObject jsonObject) throws FormException {
return req.bindJSON(GitBlitRepositoryBrowser.class, jsonObject);
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/hudson/plugins/git/browser/GitLab.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import java.io.IOException;
import java.net.URL;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import javax.servlet.ServletException;
import jakarta.servlet.ServletException;

import org.kohsuke.stapler.QueryParameter;

Expand Down Expand Up @@ -145,7 +145,7 @@ public String getDisplayName() {
@Override
@SuppressFBWarnings(value = "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
justification = "Inherited javadoc commits that req is non-null")
public GitLab newInstance(StaplerRequest req, @NonNull JSONObject jsonObject) throws FormException {
public GitLab newInstance(StaplerRequest2 req, @NonNull JSONObject jsonObject) throws FormException {
return req.bindJSON(GitLab.class, jsonObject);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/git/browser/GitList.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand Down Expand Up @@ -94,7 +94,7 @@ public String getDisplayName() {
@Override
@SuppressFBWarnings(value = "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
justification = "Inherited javadoc commits that req is non-null")
public GitList newInstance(StaplerRequest req, @NonNull JSONObject jsonObject) throws FormException {
public GitList newInstance(StaplerRequest2 req, @NonNull JSONObject jsonObject) throws FormException {
return req.bindJSON(GitList.class, jsonObject);
}
}
Expand Down
Loading

0 comments on commit 436ae20

Please sign in to comment.