From 458943b7994276e0603be24e90941d7f4fa3d91b Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 2 Jan 2024 15:34:05 -0800 Subject: [PATCH 1/2] Require Jenkins 2.414.3 LTS or newer --- Jenkinsfile | 2 +- pom.xml | 57 +++++++++++++++++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ed59448df..3a845e753 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ buildPlugin(useContainerAgent: true, configurations: [ + [platform: 'linux', jdk: 21], [platform: 'linux', jdk: 17], - [platform: 'linux', jdk: 11], ]) diff --git a/pom.xml b/pom.xml index 0569d55c9..d5837e9a4 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 4.66 + 4.76 @@ -54,7 +54,7 @@ - 2.410 + 2.414.3 2.39.4 -SNAPSHOT jenkinsci/${project.artifactId}-plugin @@ -62,6 +62,7 @@ false false + 2.5.0 2.16 3 0.5C @@ -74,16 +75,26 @@ gerrit-events 2.21.0 + + + com.google.code.gson + gson + + + + com.jcraft + jsch + commons-io commons-io - net.sf.json-lib json-lib + org.apache.httpcomponents httpclient @@ -96,6 +107,10 @@ + + io.jenkins.plugins + gson-api + org.jenkins-ci.plugins apache-httpcomponents-client-4-api @@ -115,6 +130,10 @@ rebuild true + + org.jenkins-ci.plugins + jsch + org.jenkins-ci.plugins rabbitmq-consumer @@ -237,37 +256,27 @@ com.sonyericsson.jenkins.plugins.bfa build-failure-analyzer - 2.4.0 + ${build-failure-analyzer-plugin.version} tests test com.sonyericsson.jenkins.plugins.bfa build-failure-analyzer - 2.4.0 + ${build-failure-analyzer-plugin.version} test - - - io.jenkins.tools.bom - bom-2.401.x - 2244.vd60654536b_96 - pom - import - - - com.google.code.gson - gson - 2.8.9 - - - org.apache.commons - commons-lang3 - 3.12.0 - - + + + io.jenkins.tools.bom + bom-2.414.x + 2675.v1515e14da_7a_6 + pom + import + + From d32d5251cce4068fcaab5e2acc2f3a6aa3bb7cb7 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 2 Jan 2024 16:56:30 -0800 Subject: [PATCH 2/2] Adapt to https://github.com/jenkinsci/jenkins/pull/8048 --- .../ReplicationQueueTaskDispatcherTest.java | 7 ++- .../java/hudson/model/MockBuildableItem.java | 49 +++++++++++++++++ .../java/hudson/model/MockWaitingItem.java | 55 +++++++++++++++++++ 3 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 src/test/java/hudson/model/MockBuildableItem.java create mode 100644 src/test/java/hudson/model/MockWaitingItem.java diff --git a/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/replication/ReplicationQueueTaskDispatcherTest.java b/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/replication/ReplicationQueueTaskDispatcherTest.java index 63193b68f..c45c2f82e 100644 --- a/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/replication/ReplicationQueueTaskDispatcherTest.java +++ b/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/replication/ReplicationQueueTaskDispatcherTest.java @@ -39,9 +39,10 @@ import hudson.model.Action; import hudson.model.AbstractProject; import hudson.model.CauseAction; +import hudson.model.MockBuildableItem; +import hudson.model.MockWaitingItem; import hudson.model.Queue; import hudson.model.Queue.Item; -import hudson.model.Queue.WaitingItem; import hudson.model.queue.CauseOfBlockage; import java.util.ArrayList; @@ -214,7 +215,7 @@ public void shouldNotBlockBuildableItem() { "refs/changes/1/1/1"); Item item = createItem(patchsetCreated, new String[] {"slaveA", "slaveB", "slaveC"}); - CauseOfBlockage cause = dispatcher.canRun(new Queue.BuildableItem((WaitingItem)item)); + CauseOfBlockage cause = dispatcher.canRun(new MockBuildableItem(item)); assertNull("Build should not be blocked", cause); } @@ -779,6 +780,6 @@ private Item createItem(GerritCause gerritCause, String[] slaves) { } when(gerritTriggerMock.gerritSlavesToWaitFor(any(String.class))).thenReturn(gerritSlaves); } - return new WaitingItem(Calendar.getInstance(), abstractProjectMock, actions); + return new MockWaitingItem(abstractProjectMock, actions); } } diff --git a/src/test/java/hudson/model/MockBuildableItem.java b/src/test/java/hudson/model/MockBuildableItem.java new file mode 100644 index 000000000..76b114180 --- /dev/null +++ b/src/test/java/hudson/model/MockBuildableItem.java @@ -0,0 +1,49 @@ +package hudson.model; + +import hudson.model.queue.CauseOfBlockage; + +/** + * Mock version of {@link Queue.BuildableItem} (which is final) that avoids {@link jenkins.model.TransientActionFactory}. + */ +public class MockBuildableItem extends Queue.Item { + + /** + * Create a new mock buildable item. + * + * @param item The item. + */ + public MockBuildableItem(Queue.Item item) { + super(item); + } + + @SuppressWarnings("deprecation") // avoid TransientActionFactory + @Override + public T getAction(Class type) { + for (Action a : getActions()) { + if (type.isInstance(a)) { + return type.cast(a); + } + } + return null; + } + + @Override + public boolean isBuildable() { + return true; + } + + @Override + public CauseOfBlockage getCauseOfBlockage() { + throw new UnsupportedOperationException(); + } + + @Override + void enter(Queue q) { + throw new UnsupportedOperationException(); + } + + @Override + boolean leave(Queue q) { + throw new UnsupportedOperationException(); + } +} diff --git a/src/test/java/hudson/model/MockWaitingItem.java b/src/test/java/hudson/model/MockWaitingItem.java new file mode 100644 index 000000000..00c48a797 --- /dev/null +++ b/src/test/java/hudson/model/MockWaitingItem.java @@ -0,0 +1,55 @@ +package hudson.model; + +import hudson.model.queue.CauseOfBlockage; +import hudson.model.queue.FutureImpl; +import java.util.List; +import java.util.concurrent.atomic.AtomicLong; + +/** + * Mock version of {@link Queue.WaitingItem} (which is final) that avoids {@link jenkins.model.TransientActionFactory}. + */ +public class MockWaitingItem extends Queue.Item { + + private static final AtomicLong COUNTER = new AtomicLong(0); + + /** + * Create a new mock waiting item. + * + * @param project The project. + * @param actions The actions. + */ + public MockWaitingItem(Queue.Task project, List actions) { + super(project, actions, COUNTER.incrementAndGet(), new FutureImpl(project)); + } + + @SuppressWarnings("deprecation") // avoid TransientActionFactory + @Override + public T getAction(Class type) { + for (Action a : getActions()) { + if (type.isInstance(a)) { + return type.cast(a); + } + } + return null; + } + + @Override + public boolean isBuildable() { + return false; + } + + @Override + public CauseOfBlockage getCauseOfBlockage() { + throw new UnsupportedOperationException(); + } + + @Override + void enter(Queue q) { + throw new UnsupportedOperationException(); + } + + @Override + boolean leave(Queue q) { + throw new UnsupportedOperationException(); + } +}