Skip to content

Commit

Permalink
Migrate from EE 8 to EE 9 (#1637)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Jan 23, 2025
1 parent c91e951 commit 8b0d329
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 52 deletions.
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ properties([

def splits
stage('Determine splits') {
node('maven-11') {
node('maven-17') {
checkout scm
splits = splitTests parallelism: count(2), generateInclusions: true, estimateTestsFromFiles: true
}
Expand Down Expand Up @@ -51,9 +51,9 @@ stage('Tests') {
}
}
}
branches['jdk11'] = {
branches['jdk17'] = {
retry(count: 3, conditions: [kubernetesAgent(handleNonKubernetes: true), nonresumable()]) {
node('maven-11') {
node('maven-17') {
timeout(60) {
checkout scm
sh 'mvn -B -ntp -Dset.changelist -Dmaven.test.failure.ignore clean install'
Expand Down
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.5</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -43,8 +43,8 @@
<changelist>999999-SNAPSHOT</changelist>
<jenkins.host.address />
<slaveAgentPort />
<jenkins.baseline>2.426</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<jenkins.baseline>2.479</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
<no-test-jar>false</no-test-jar>
<useBeta>true</useBeta>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
Expand All @@ -58,7 +58,7 @@
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-${jenkins.baseline}.x</artifactId>
<version>2857.v01a_0144eb_20b_</version>
<version>3850.vb_c5319efa_e29</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.VersionInfo;
import io.fabric8.kubernetes.client.informers.SharedIndexInformer;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.io.StringReader;
import java.net.ConnectException;
Expand All @@ -61,7 +62,6 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import jenkins.authentication.tokens.api.AuthenticationTokens;
import jenkins.bouncycastle.api.PEMEncodable;
import jenkins.metrics.api.Metrics;
Expand All @@ -87,8 +87,8 @@
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.Stapler;
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;
import org.kohsuke.stapler.verb.POST;

Expand Down Expand Up @@ -924,7 +924,7 @@ public PodTemplate.DescriptorImpl getTemplateDescriptor() {
* Creating a new template.
*/
@POST
public HttpResponse doCreate(StaplerRequest req, StaplerResponse rsp)
public HttpResponse doCreate(StaplerRequest2 req, StaplerResponse2 rsp)
throws IOException, ServletException, Descriptor.FormException {
Jenkins j = Jenkins.get();
j.checkPermission(Jenkins.MANAGE);
Expand Down Expand Up @@ -1154,7 +1154,7 @@ private static boolean hasPermission(AccessControlled owner) {
LOGGER.log(
Level.WARNING,
() -> "Unsupported owner type " + (owner == null ? "null" : owner.getClass()) + " (url: "
+ Stapler.getCurrentRequest().getOriginalRequestURI()
+ Stapler.getCurrentRequest2().getOriginalRequestURI()
+ "). Please report this issue to the plugin maintainers.");
return false;
}
Expand All @@ -1170,7 +1170,7 @@ private static void checkPermission(AccessControlled owner) {
} else {
throw new IllegalArgumentException(
"Unsupported owner type " + (owner == null ? "null" : owner.getClass()) + " (url: "
+ Stapler.getCurrentRequest().getOriginalRequestURI()
+ Stapler.getCurrentRequest2().getOriginalRequestURI()
+ "). Please report this issue to the plugin maintainers.");
}
}
Expand Down Expand Up @@ -1310,7 +1310,7 @@ private Object readResolve() {
}

@Override
public Cloud reconfigure(@NonNull StaplerRequest req, JSONObject form) throws Descriptor.FormException {
public Cloud reconfigure(@NonNull StaplerRequest2 req, JSONObject form) throws Descriptor.FormException {
// cloud configuration doesn't contain templates anymore, so just keep existing ones.
var newInstance = (KubernetesCloud) super.reconfigure(req, form);
newInstance.setTemplates(this.templates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.kubernetes.auth.KubernetesAuthException;
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 org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.framework.io.ByteBuffer;
import org.kohsuke.stapler.framework.io.LargeText;
Expand Down Expand Up @@ -132,7 +132,7 @@ public List<Event> getPodEvents() throws KubernetesAuthException, IOException {
return Collections.emptyList();
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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;

/**
* Provides folder level Kubernetes configuration.
Expand Down Expand Up @@ -73,7 +73,7 @@ public static boolean isAllowed(KubernetesSlave agent, Job job) {
}

@Override
public AbstractFolderProperty<?> reconfigure(StaplerRequest req, JSONObject form) throws FormException {
public AbstractFolderProperty<?> reconfigure(StaplerRequest2 req, JSONObject form) throws FormException {
// ignore modifications silently and return the unmodified object if the user
// does not have the ADMINISTER Permission
if (!userHasAdministerPermission()) {
Expand Down Expand Up @@ -200,7 +200,7 @@ public String getDisplayName() {
@SuppressWarnings("unused") // Used by jelly
@Restricted(DoNotUse.class)
public List<UsagePermission> getEffectivePermissions() {
Set<String> inheritedClouds = getInheritedClouds(Stapler.getCurrentRequest()
Set<String> inheritedClouds = getInheritedClouds(Stapler.getCurrentRequest2()
.findAncestorObject(AbstractFolder.class)
.getParent());
List<UsagePermission> ps = getUsageRestrictedKubernetesClouds().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.stream.Collectors;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

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

@Override
public Cloud reconfigure(@NonNull StaplerRequest req, JSONObject form) throws Descriptor.FormException {
public Cloud reconfigure(@NonNull StaplerRequest2 req, JSONObject form) throws Descriptor.FormException {
return DescriptorImpl.class.cast(getDescriptor()).newInstance(req, form);
}

Expand Down Expand Up @@ -54,12 +54,12 @@ public String getDisplayName() {
}

@Override
public boolean configure(StaplerRequest request, JSONObject object) throws Descriptor.FormException {
public boolean configure(StaplerRequest2 request, JSONObject object) throws Descriptor.FormException {
return true;
}

@Override
public Cloud newInstance(StaplerRequest req, JSONObject formData) throws Descriptor.FormException {
public Cloud newInstance(StaplerRequest2 req, JSONObject formData) throws Descriptor.FormException {
if (req != null) {
// We prevent the cloud reconfiguration from the web UI
String cloudName = req.getParameter("cloudName");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.cloudbees.plugins.credentials.CredentialsScope;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.model.Descriptor;
import org.kohsuke.stapler.DataBoundConstructor;

/**
Expand All @@ -16,7 +17,8 @@ public class OpenShiftBearerTokenCredentialImpl

@DataBoundConstructor
public OpenShiftBearerTokenCredentialImpl(
CredentialsScope scope, String id, String description, String username, String password) {
CredentialsScope scope, String id, String description, String username, String password)
throws Descriptor.FormException {
super(scope, id, description, username, password);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import hudson.util.XStream2;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.client.KubernetesClient;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringReader;
Expand All @@ -37,7 +38,6 @@
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
Expand All @@ -54,7 +54,7 @@
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.HttpRedirect;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.verb.POST;

/**
Expand Down Expand Up @@ -691,7 +691,7 @@ public HttpResponse doDoDelete(@AncestorInPath PodTemplateGroup owner) throws IO
}

@POST
public HttpResponse doConfigSubmit(StaplerRequest req, @AncestorInPath PodTemplateGroup owner)
public HttpResponse doConfigSubmit(StaplerRequest2 req, @AncestorInPath PodTemplateGroup owner)
throws IOException, ServletException, Descriptor.FormException {
Jenkins j = Jenkins.get();
j.checkPermission(Jenkins.MANAGE);
Expand All @@ -705,7 +705,7 @@ public HttpResponse doConfigSubmit(StaplerRequest req, @AncestorInPath PodTempla
return FormApply.success(owner.getPodTemplateGroupUrl());
}

private PodTemplate reconfigure(@NonNull final StaplerRequest req, JSONObject form)
private PodTemplate reconfigure(@NonNull final StaplerRequest2 req, JSONObject form)
throws Descriptor.FormException {
if (form == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM jenkins/inbound-agent:3283.v92c105e0f819-4
FROM jenkins/inbound-agent:3283.v92c105e0f819-7
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.kohsuke.stapler.StaplerRequest2;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
Expand Down Expand Up @@ -59,14 +60,14 @@ public void setUpTwoClouds() throws Exception {
JSONObject json1 = new JSONObject();
json1.element("usage-permission-A", true);
json1.element("usage-permission-B", false);
folderA.addProperty(property1.reconfigure(null, json1));
folderA.addProperty(property1.reconfigure((StaplerRequest2) null, json1));

KubernetesFolderProperty property2 = new KubernetesFolderProperty();
folderB.addProperty(property2);
JSONObject json2 = new JSONObject();
json2.element("usage-permission-A", false);
json2.element("usage-permission-B", true);
folderB.addProperty(property2.reconfigure(null, json2));
folderB.addProperty(property2.reconfigure((StaplerRequest2) null, json2));

slaveA = new KubernetesSlave(
"A", new PodTemplate(), "testA", "A", "dockerA", new KubernetesLauncher(), RetentionStrategy.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand Down Expand Up @@ -293,13 +292,12 @@ public static String generateProjectName(String name) {
}

public static WorkflowRun createPipelineJobThenScheduleRun(JenkinsRule r, Class cls, String methodName)
throws InterruptedException, ExecutionException, IOException {
throws Exception {
return createPipelineJobThenScheduleRun(r, cls, methodName, null);
}

public static WorkflowRun createPipelineJobThenScheduleRun(
JenkinsRule r, Class cls, String methodName, Map<String, String> env)
throws IOException, ExecutionException, InterruptedException {
JenkinsRule r, Class cls, String methodName, Map<String, String> env) throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, generateProjectName(methodName));
p.setDefinition(new CpsFlowDefinition(loadPipelineDefinition(cls, methodName, env), true));
return p.scheduleBuild2(0).waitForStart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.jenkins.plugins.kubernetes.NoDelayProvisionerStrategy;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import java.util.stream.Collectors;
import org.csanchez.jenkins.plugins.kubernetes.ContainerEnvVar;
Expand Down Expand Up @@ -118,12 +116,8 @@ protected String getProjectName() {
* to the method name within the pipeline definition.
*
* @return The scheduled pipeline run
* @throws IOException If something gets wrong when creating the pipeline job
* @throws ExecutionException If something went wrong while retrieving the run object
* @throws InterruptedException If the thread gets interrupted while waiting for the run to start
*/
protected final WorkflowRun createJobThenScheduleRun()
throws IOException, ExecutionException, InterruptedException {
protected final WorkflowRun createJobThenScheduleRun() throws Exception {
return createJobThenScheduleRun(null);
}

Expand All @@ -136,12 +130,8 @@ protected final WorkflowRun createJobThenScheduleRun()
*
* @param env an environment map to resolve in the pipeline script
* @return The scheduled pipeline run
* @throws IOException If something gets wrong when creating the pipeline job
* @throws ExecutionException If something went wrong while retrieving the run object
* @throws InterruptedException If the thread gets interrupted while waiting for the run to start
*/
protected final WorkflowRun createJobThenScheduleRun(Map<String, String> env)
throws IOException, ExecutionException, InterruptedException {
protected final WorkflowRun createJobThenScheduleRun(Map<String, String> env) throws Exception {
b = createPipelineJobThenScheduleRun(r, getClass(), name.getMethodName(), env);
p = b.getParent();
return b;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.io.IOException;
import java.util.Collections;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -352,8 +351,7 @@ public void getContainerLogWithRestart() throws Exception, Throwable {
});
}

private WorkflowRun getPipelineJobThenScheduleRun(JenkinsRule r)
throws InterruptedException, ExecutionException, IOException {
private WorkflowRun getPipelineJobThenScheduleRun(JenkinsRule r) throws Exception {
return createPipelineJobThenScheduleRun(r, getClass(), name.getMethodName());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
podTemplate(containers: [
containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:3077.vd69cf116da_6f-3-jdk11', workingDir: '/home/jenkins'),
containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:3283.v92c105e0f819-7', workingDir: '/home/jenkins'),
containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat')
]) {
node (POD_LABEL) {
Expand Down

0 comments on commit 8b0d329

Please sign in to comment.