Skip to content

Commit 8b0d329

Browse files
authored
Migrate from EE 8 to EE 9 (#1637)
1 parent c91e951 commit 8b0d329

File tree

14 files changed

+41
-52
lines changed

14 files changed

+41
-52
lines changed

Jenkinsfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ properties([
66

77
def splits
88
stage('Determine splits') {
9-
node('maven-11') {
9+
node('maven-17') {
1010
checkout scm
1111
splits = splitTests parallelism: count(2), generateInclusions: true, estimateTestsFromFiles: true
1212
}
@@ -51,9 +51,9 @@ stage('Tests') {
5151
}
5252
}
5353
}
54-
branches['jdk11'] = {
54+
branches['jdk17'] = {
5555
retry(count: 3, conditions: [kubernetesAgent(handleNonKubernetes: true), nonresumable()]) {
56-
node('maven-11') {
56+
node('maven-17') {
5757
timeout(60) {
5858
checkout scm
5959
sh 'mvn -B -ntp -Dset.changelist -Dmaven.test.failure.ignore clean install'

pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.jenkins-ci.plugins</groupId>
66
<artifactId>plugin</artifactId>
7-
<version>4.88</version>
7+
<version>5.5</version>
88
<relativePath />
99
</parent>
1010

@@ -43,8 +43,8 @@
4343
<changelist>999999-SNAPSHOT</changelist>
4444
<jenkins.host.address />
4545
<slaveAgentPort />
46-
<jenkins.baseline>2.426</jenkins.baseline>
47-
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
46+
<jenkins.baseline>2.479</jenkins.baseline>
47+
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
4848
<no-test-jar>false</no-test-jar>
4949
<useBeta>true</useBeta>
5050
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
@@ -58,7 +58,7 @@
5858
<dependency>
5959
<groupId>io.jenkins.tools.bom</groupId>
6060
<artifactId>bom-${jenkins.baseline}.x</artifactId>
61-
<version>2857.v01a_0144eb_20b_</version>
61+
<version>3850.vb_c5319efa_e29</version>
6262
<type>pom</type>
6363
<scope>import</scope>
6464
</dependency>

src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import io.fabric8.kubernetes.client.KubernetesClientException;
3636
import io.fabric8.kubernetes.client.VersionInfo;
3737
import io.fabric8.kubernetes.client.informers.SharedIndexInformer;
38+
import jakarta.servlet.ServletException;
3839
import java.io.IOException;
3940
import java.io.StringReader;
4041
import java.net.ConnectException;
@@ -61,7 +62,6 @@
6162
import java.util.concurrent.TimeUnit;
6263
import java.util.logging.Level;
6364
import java.util.logging.Logger;
64-
import javax.servlet.ServletException;
6565
import jenkins.authentication.tokens.api.AuthenticationTokens;
6666
import jenkins.bouncycastle.api.PEMEncodable;
6767
import jenkins.metrics.api.Metrics;
@@ -87,8 +87,8 @@
8787
import org.kohsuke.stapler.HttpResponse;
8888
import org.kohsuke.stapler.QueryParameter;
8989
import org.kohsuke.stapler.Stapler;
90-
import org.kohsuke.stapler.StaplerRequest;
91-
import org.kohsuke.stapler.StaplerResponse;
90+
import org.kohsuke.stapler.StaplerRequest2;
91+
import org.kohsuke.stapler.StaplerResponse2;
9292
import org.kohsuke.stapler.interceptor.RequirePOST;
9393
import org.kohsuke.stapler.verb.POST;
9494

@@ -924,7 +924,7 @@ public PodTemplate.DescriptorImpl getTemplateDescriptor() {
924924
* Creating a new template.
925925
*/
926926
@POST
927-
public HttpResponse doCreate(StaplerRequest req, StaplerResponse rsp)
927+
public HttpResponse doCreate(StaplerRequest2 req, StaplerResponse2 rsp)
928928
throws IOException, ServletException, Descriptor.FormException {
929929
Jenkins j = Jenkins.get();
930930
j.checkPermission(Jenkins.MANAGE);
@@ -1154,7 +1154,7 @@ private static boolean hasPermission(AccessControlled owner) {
11541154
LOGGER.log(
11551155
Level.WARNING,
11561156
() -> "Unsupported owner type " + (owner == null ? "null" : owner.getClass()) + " (url: "
1157-
+ Stapler.getCurrentRequest().getOriginalRequestURI()
1157+
+ Stapler.getCurrentRequest2().getOriginalRequestURI()
11581158
+ "). Please report this issue to the plugin maintainers.");
11591159
return false;
11601160
}
@@ -1170,7 +1170,7 @@ private static void checkPermission(AccessControlled owner) {
11701170
} else {
11711171
throw new IllegalArgumentException(
11721172
"Unsupported owner type " + (owner == null ? "null" : owner.getClass()) + " (url: "
1173-
+ Stapler.getCurrentRequest().getOriginalRequestURI()
1173+
+ Stapler.getCurrentRequest2().getOriginalRequestURI()
11741174
+ "). Please report this issue to the plugin maintainers.");
11751175
}
11761176
}
@@ -1310,7 +1310,7 @@ private Object readResolve() {
13101310
}
13111311

13121312
@Override
1313-
public Cloud reconfigure(@NonNull StaplerRequest req, JSONObject form) throws Descriptor.FormException {
1313+
public Cloud reconfigure(@NonNull StaplerRequest2 req, JSONObject form) throws Descriptor.FormException {
13141314
// cloud configuration doesn't contain templates anymore, so just keep existing ones.
13151315
var newInstance = (KubernetesCloud) super.reconfigure(req, form);
13161316
newInstance.setTemplates(this.templates);

src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesComputer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import org.apache.commons.lang.StringUtils;
2828
import org.jenkinsci.plugins.kubernetes.auth.KubernetesAuthException;
2929
import org.kohsuke.stapler.QueryParameter;
30-
import org.kohsuke.stapler.StaplerRequest;
31-
import org.kohsuke.stapler.StaplerResponse;
30+
import org.kohsuke.stapler.StaplerRequest2;
31+
import org.kohsuke.stapler.StaplerResponse2;
3232
import org.kohsuke.stapler.export.Exported;
3333
import org.kohsuke.stapler.framework.io.ByteBuffer;
3434
import org.kohsuke.stapler.framework.io.LargeText;
@@ -132,7 +132,7 @@ public List<Event> getPodEvents() throws KubernetesAuthException, IOException {
132132
return Collections.emptyList();
133133
}
134134

135-
public void doContainerLog(@QueryParameter String containerId, StaplerRequest req, StaplerResponse rsp)
135+
public void doContainerLog(@QueryParameter String containerId, StaplerRequest2 req, StaplerResponse2 rsp)
136136
throws KubernetesAuthException, IOException {
137137
Jenkins.get().checkPermission(Computer.EXTENDED_READ);
138138

src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesFolderProperty.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.kohsuke.stapler.DataBoundConstructor;
2828
import org.kohsuke.stapler.DataBoundSetter;
2929
import org.kohsuke.stapler.Stapler;
30-
import org.kohsuke.stapler.StaplerRequest;
30+
import org.kohsuke.stapler.StaplerRequest2;
3131

3232
/**
3333
* Provides folder level Kubernetes configuration.
@@ -73,7 +73,7 @@ public static boolean isAllowed(KubernetesSlave agent, Job job) {
7373
}
7474

7575
@Override
76-
public AbstractFolderProperty<?> reconfigure(StaplerRequest req, JSONObject form) throws FormException {
76+
public AbstractFolderProperty<?> reconfigure(StaplerRequest2 req, JSONObject form) throws FormException {
7777
// ignore modifications silently and return the unmodified object if the user
7878
// does not have the ADMINISTER Permission
7979
if (!userHasAdministerPermission()) {
@@ -200,7 +200,7 @@ public String getDisplayName() {
200200
@SuppressWarnings("unused") // Used by jelly
201201
@Restricted(DoNotUse.class)
202202
public List<UsagePermission> getEffectivePermissions() {
203-
Set<String> inheritedClouds = getInheritedClouds(Stapler.getCurrentRequest()
203+
Set<String> inheritedClouds = getInheritedClouds(Stapler.getCurrentRequest2()
204204
.findAncestorObject(AbstractFolder.class)
205205
.getParent());
206206
List<UsagePermission> ps = getUsageRestrictedKubernetesClouds().stream()

src/main/java/org/csanchez/jenkins/plugins/kubernetes/NonConfigurableKubernetesCloud.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.util.stream.Collectors;
1010
import jenkins.model.Jenkins;
1111
import net.sf.json.JSONObject;
12-
import org.kohsuke.stapler.StaplerRequest;
12+
import org.kohsuke.stapler.StaplerRequest2;
1313

1414
public class NonConfigurableKubernetesCloud extends KubernetesCloud {
1515
public NonConfigurableKubernetesCloud(@NonNull String name, @NonNull KubernetesCloud source) {
@@ -26,7 +26,7 @@ public void addTemplate(PodTemplate template) {}
2626
public void removeTemplate(PodTemplate template) {}
2727

2828
@Override
29-
public Cloud reconfigure(@NonNull StaplerRequest req, JSONObject form) throws Descriptor.FormException {
29+
public Cloud reconfigure(@NonNull StaplerRequest2 req, JSONObject form) throws Descriptor.FormException {
3030
return DescriptorImpl.class.cast(getDescriptor()).newInstance(req, form);
3131
}
3232

@@ -54,12 +54,12 @@ public String getDisplayName() {
5454
}
5555

5656
@Override
57-
public boolean configure(StaplerRequest request, JSONObject object) throws Descriptor.FormException {
57+
public boolean configure(StaplerRequest2 request, JSONObject object) throws Descriptor.FormException {
5858
return true;
5959
}
6060

6161
@Override
62-
public Cloud newInstance(StaplerRequest req, JSONObject formData) throws Descriptor.FormException {
62+
public Cloud newInstance(StaplerRequest2 req, JSONObject formData) throws Descriptor.FormException {
6363
if (req != null) {
6464
// We prevent the cloud reconfiguration from the web UI
6565
String cloudName = req.getParameter("cloudName");

src/main/java/org/csanchez/jenkins/plugins/kubernetes/OpenShiftBearerTokenCredentialImpl.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.cloudbees.plugins.credentials.CredentialsScope;
44
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
5+
import hudson.model.Descriptor;
56
import org.kohsuke.stapler.DataBoundConstructor;
67

78
/**
@@ -16,7 +17,8 @@ public class OpenShiftBearerTokenCredentialImpl
1617

1718
@DataBoundConstructor
1819
public OpenShiftBearerTokenCredentialImpl(
19-
CredentialsScope scope, String id, String description, String username, String password) {
20+
CredentialsScope scope, String id, String description, String username, String password)
21+
throws Descriptor.FormException {
2022
super(scope, id, description, username, password);
2123
}
2224
}

src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import hudson.util.XStream2;
2121
import io.fabric8.kubernetes.api.model.Pod;
2222
import io.fabric8.kubernetes.client.KubernetesClient;
23+
import jakarta.servlet.ServletException;
2324
import java.io.IOException;
2425
import java.io.Serializable;
2526
import java.io.StringReader;
@@ -37,7 +38,6 @@
3738
import java.util.UUID;
3839
import java.util.logging.Level;
3940
import java.util.logging.Logger;
40-
import javax.servlet.ServletException;
4141
import jenkins.model.Jenkins;
4242
import net.sf.json.JSONObject;
4343
import org.apache.commons.lang.StringUtils;
@@ -54,7 +54,7 @@
5454
import org.kohsuke.stapler.DataBoundSetter;
5555
import org.kohsuke.stapler.HttpRedirect;
5656
import org.kohsuke.stapler.HttpResponse;
57-
import org.kohsuke.stapler.StaplerRequest;
57+
import org.kohsuke.stapler.StaplerRequest2;
5858
import org.kohsuke.stapler.verb.POST;
5959

6060
/**
@@ -691,7 +691,7 @@ public HttpResponse doDoDelete(@AncestorInPath PodTemplateGroup owner) throws IO
691691
}
692692

693693
@POST
694-
public HttpResponse doConfigSubmit(StaplerRequest req, @AncestorInPath PodTemplateGroup owner)
694+
public HttpResponse doConfigSubmit(StaplerRequest2 req, @AncestorInPath PodTemplateGroup owner)
695695
throws IOException, ServletException, Descriptor.FormException {
696696
Jenkins j = Jenkins.get();
697697
j.checkPermission(Jenkins.MANAGE);
@@ -705,7 +705,7 @@ public HttpResponse doConfigSubmit(StaplerRequest req, @AncestorInPath PodTempla
705705
return FormApply.success(owner.getPodTemplateGroupUrl());
706706
}
707707

708-
private PodTemplate reconfigure(@NonNull final StaplerRequest req, JSONObject form)
708+
private PodTemplate reconfigure(@NonNull final StaplerRequest2 req, JSONObject form)
709709
throws Descriptor.FormException {
710710
if (form == null) {
711711
return null;
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM jenkins/inbound-agent:3283.v92c105e0f819-4
1+
FROM jenkins/inbound-agent:3283.v92c105e0f819-7

src/test/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesQueueTaskDispatcherTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.junit.Rule;
2020
import org.junit.Test;
2121
import org.jvnet.hudson.test.JenkinsRule;
22+
import org.kohsuke.stapler.StaplerRequest2;
2223
import org.mockito.Mock;
2324
import org.mockito.junit.MockitoJUnit;
2425
import org.mockito.junit.MockitoRule;
@@ -59,14 +60,14 @@ public void setUpTwoClouds() throws Exception {
5960
JSONObject json1 = new JSONObject();
6061
json1.element("usage-permission-A", true);
6162
json1.element("usage-permission-B", false);
62-
folderA.addProperty(property1.reconfigure(null, json1));
63+
folderA.addProperty(property1.reconfigure((StaplerRequest2) null, json1));
6364

6465
KubernetesFolderProperty property2 = new KubernetesFolderProperty();
6566
folderB.addProperty(property2);
6667
JSONObject json2 = new JSONObject();
6768
json2.element("usage-permission-A", false);
6869
json2.element("usage-permission-B", true);
69-
folderB.addProperty(property2.reconfigure(null, json2));
70+
folderB.addProperty(property2.reconfigure((StaplerRequest2) null, json2));
7071

7172
slaveA = new KubernetesSlave(
7273
"A", new PodTemplate(), "testA", "A", "dockerA", new KubernetesLauncher(), RetentionStrategy.INSTANCE);

src/test/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesTestUtil.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import java.util.HashMap;
5050
import java.util.List;
5151
import java.util.Map;
52-
import java.util.concurrent.ExecutionException;
5352
import java.util.concurrent.ForkJoinPool;
5453
import java.util.concurrent.TimeUnit;
5554
import java.util.concurrent.TimeoutException;
@@ -293,13 +292,12 @@ public static String generateProjectName(String name) {
293292
}
294293

295294
public static WorkflowRun createPipelineJobThenScheduleRun(JenkinsRule r, Class cls, String methodName)
296-
throws InterruptedException, ExecutionException, IOException {
295+
throws Exception {
297296
return createPipelineJobThenScheduleRun(r, cls, methodName, null);
298297
}
299298

300299
public static WorkflowRun createPipelineJobThenScheduleRun(
301-
JenkinsRule r, Class cls, String methodName, Map<String, String> env)
302-
throws IOException, ExecutionException, InterruptedException {
300+
JenkinsRule r, Class cls, String methodName, Map<String, String> env) throws Exception {
303301
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, generateProjectName(methodName));
304302
p.setDefinition(new CpsFlowDefinition(loadPipelineDefinition(cls, methodName, env), true));
305303
return p.scheduleBuild2(0).waitForStart();

src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/AbstractKubernetesPipelineTest.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@
3737
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
3838
import io.fabric8.kubernetes.client.KubernetesClient;
3939
import io.jenkins.plugins.kubernetes.NoDelayProvisionerStrategy;
40-
import java.io.IOException;
4140
import java.util.Arrays;
4241
import java.util.List;
4342
import java.util.Map;
44-
import java.util.concurrent.ExecutionException;
4543
import java.util.logging.Level;
4644
import java.util.stream.Collectors;
4745
import org.csanchez.jenkins.plugins.kubernetes.ContainerEnvVar;
@@ -118,12 +116,8 @@ protected String getProjectName() {
118116
* to the method name within the pipeline definition.
119117
*
120118
* @return The scheduled pipeline run
121-
* @throws IOException If something gets wrong when creating the pipeline job
122-
* @throws ExecutionException If something went wrong while retrieving the run object
123-
* @throws InterruptedException If the thread gets interrupted while waiting for the run to start
124119
*/
125-
protected final WorkflowRun createJobThenScheduleRun()
126-
throws IOException, ExecutionException, InterruptedException {
120+
protected final WorkflowRun createJobThenScheduleRun() throws Exception {
127121
return createJobThenScheduleRun(null);
128122
}
129123

@@ -136,12 +130,8 @@ protected final WorkflowRun createJobThenScheduleRun()
136130
*
137131
* @param env an environment map to resolve in the pipeline script
138132
* @return The scheduled pipeline run
139-
* @throws IOException If something gets wrong when creating the pipeline job
140-
* @throws ExecutionException If something went wrong while retrieving the run object
141-
* @throws InterruptedException If the thread gets interrupted while waiting for the run to start
142133
*/
143-
protected final WorkflowRun createJobThenScheduleRun(Map<String, String> env)
144-
throws IOException, ExecutionException, InterruptedException {
134+
protected final WorkflowRun createJobThenScheduleRun(Map<String, String> env) throws Exception {
145135
b = createPipelineJobThenScheduleRun(r, getClass(), name.getMethodName(), env);
146136
p = b.getParent();
147137
return b;

src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/RestartPipelineTest.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.io.IOException;
3636
import java.util.Collections;
3737
import java.util.Optional;
38-
import java.util.concurrent.ExecutionException;
3938
import java.util.concurrent.atomic.AtomicReference;
4039
import java.util.logging.Level;
4140
import java.util.logging.Logger;
@@ -352,8 +351,7 @@ public void getContainerLogWithRestart() throws Exception, Throwable {
352351
});
353352
}
354353

355-
private WorkflowRun getPipelineJobThenScheduleRun(JenkinsRule r)
356-
throws InterruptedException, ExecutionException, IOException {
354+
private WorkflowRun getPipelineJobThenScheduleRun(JenkinsRule r) throws Exception {
357355
return createPipelineJobThenScheduleRun(r, getClass(), name.getMethodName());
358356
}
359357
}

src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/jnlpWorkingDir.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
podTemplate(containers: [
2-
containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:3077.vd69cf116da_6f-3-jdk11', workingDir: '/home/jenkins'),
2+
containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:3283.v92c105e0f819-7', workingDir: '/home/jenkins'),
33
containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat')
44
]) {
55
node (POD_LABEL) {

0 commit comments

Comments
 (0)