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

Require Jenkins 2.414.3 LTS or newer #502

Merged
merged 2 commits into from
Jan 9, 2024
Merged
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
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
buildPlugin(useContainerAgent: true, configurations: [
[platform: 'linux', jdk: 21],
[platform: 'linux', jdk: 17],
[platform: 'linux', jdk: 11],
])
57 changes: 33 additions & 24 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.66</version>
<version>4.76</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -54,14 +54,15 @@
</developers>

<properties>
<jenkins.version>2.410</jenkins.version>
<jenkins.version>2.414.3</jenkins.version>
<revision>2.39.4</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<!--<java.level>8</java.level>-->
<no-test-jar>false</no-test-jar>
<findbugs.failOnError>false</findbugs.failOnError>
<!--<concurrency>0.5C</concurrency>-->
<build-failure-analyzer-plugin.version>2.5.0</build-failure-analyzer-plugin.version>
<checkstyle.version>2.16</checkstyle.version>
<surefire.rerunFailingTestsCount>3</surefire.rerunFailingTestsCount>
<forkCount>0.5C</forkCount>
Expand All @@ -74,16 +75,26 @@
<artifactId>gerrit-events</artifactId>
<version>2.21.0</version>
<exclusions>
<!-- Provided by gson-api plugin -->
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
<!-- Provided by jsch plugin -->
<exclusion>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
</exclusion>
<!-- Provided by core -->
<exclusion>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</exclusion>
<exclusion>
<!-- json-lib-2.4-jenkins-2 is provided by core/stapler -->
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
</exclusion>
<!-- Provided by apache-httpcomponents-client-4-api plugin -->
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand All @@ -96,6 +107,10 @@
</exclusions>
<!-- New source is here: https://github.com/sonyxperiadev/gerrit-events -->
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>gson-api</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>apache-httpcomponents-client-4-api</artifactId>
Expand All @@ -115,6 +130,10 @@
<artifactId>rebuild</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jsch</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>rabbitmq-consumer</artifactId>
Expand Down Expand Up @@ -237,37 +256,27 @@
<dependency>
<groupId>com.sonyericsson.jenkins.plugins.bfa</groupId>
<artifactId>build-failure-analyzer</artifactId>
<version>2.4.0</version>
<version>${build-failure-analyzer-plugin.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sonyericsson.jenkins.plugins.bfa</groupId>
<artifactId>build-failure-analyzer</artifactId>
<version>2.4.0</version>
<version>${build-failure-analyzer-plugin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.401.x</artifactId>
<version>2244.vd60654536b_96</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.414.x</artifactId>
<version>2675.v1515e14da_7a_6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
}
49 changes: 49 additions & 0 deletions src/test/java/hudson/model/MockBuildableItem.java
Original file line number Diff line number Diff line change
@@ -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 extends Action> T getAction(Class<T> 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();
}
}
55 changes: 55 additions & 0 deletions src/test/java/hudson/model/MockWaitingItem.java
Original file line number Diff line number Diff line change
@@ -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<Action> actions) {
super(project, actions, COUNTER.incrementAndGet(), new FutureImpl(project));
}

@SuppressWarnings("deprecation") // avoid TransientActionFactory
@Override
public <T extends Action> T getAction(Class<T> 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();
}
}
Loading