Skip to content

Commit 120d270

Browse files
committed
feat(java): Require Jenkins core 2.479.1 and Java 17.
1 parent 9fecfd6 commit 120d270

File tree

4 files changed

+38
-56
lines changed

4 files changed

+38
-56
lines changed

pom.xml

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<parent>
55
<groupId>org.jenkins-ci.plugins</groupId>
66
<artifactId>plugin</artifactId>
7-
<version>3.53</version>
7+
<version>5.7</version>
8+
<relativePath></relativePath>
89
</parent>
910

1011
<artifactId>stash-pullrequest-builder</artifactId>
@@ -15,26 +16,8 @@
1516
<description>This plugin builds Stash pull requests and posts the build results on Stash</description>
1617
<url>https://github.com/jenkinsci/stash-pullrequest-builder-plugin</url>
1718

18-
<developers>
19-
<developer>
20-
<id>nemccarthy</id>
21-
<name>Nathan McCarthy</name>
22-
<email>nem@nemccarthy.me</email>
23-
</developer>
24-
<developer>
25-
<id>jimklimov</id>
26-
<name>Jim Klimov</name>
27-
<email>jimklimov@gmail.com</email>
28-
</developer>
29-
<developer>
30-
<id>jbochenski</id>
31-
<name>Jakub Bocheński</name>
32-
<email>kuba.bochenski+stash-pullrequest-builder-plugin@gmail.com</email>
33-
</developer>
34-
</developers>
35-
3619
<scm>
37-
<connection>scm:git:ssh://github.com/jenkinsci/stash-pullrequest-builder-plugin.git</connection>
20+
<connection>scm:git:https://github.com/jenkinsci/stash-pullrequest-builder-plugin.git</connection>
3821
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/stash-pullrequest-builder-plugin.git</developerConnection>
3922
<tag>${scmTag}</tag>
4023
<url>https://github.com/jenkinsci/stash-pullrequest-builder-plugin</url>
@@ -56,19 +39,22 @@
5639
<properties>
5740
<revision>1.18</revision>
5841
<changelist>-SNAPSHOT</changelist>
59-
<java.level>8</java.level>
60-
<jenkins.version>2.60.3</jenkins.version>
42+
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
43+
<jenkins.baseline>2.479</jenkins.baseline>
44+
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
45+
<slf4jVersion>1.7.25</slf4jVersion>
6146
<spotbugs.effort>Max</spotbugs.effort>
6247
<spotbugs.threshold>Low</spotbugs.threshold>
6348
</properties>
6449

6550
<dependencyManagement>
6651
<dependencies>
6752
<dependency>
68-
<groupId>junit</groupId>
69-
<artifactId>junit</artifactId>
70-
<version>4.13</version>
71-
<scope>test</scope>
53+
<groupId>io.jenkins.tools.bom</groupId>
54+
<artifactId>bom-${jenkins.baseline}.x</artifactId>
55+
<version>4136.vca_c3202a_7fd1</version>
56+
<type>pom</type>
57+
<scope>import</scope>
7258
</dependency>
7359
</dependencies>
7460
</dependencyManagement>
@@ -77,22 +63,18 @@
7763
<dependency>
7864
<groupId>org.jenkins-ci.plugins</groupId>
7965
<artifactId>jackson2-api</artifactId>
80-
<version>2.9.9.1</version>
8166
</dependency>
8267
<dependency>
8368
<groupId>org.jenkins-ci.plugins</groupId>
8469
<artifactId>credentials</artifactId>
85-
<version>2.1.5</version>
8670
</dependency>
8771
<dependency>
8872
<groupId>org.jenkins-ci.plugins</groupId>
8973
<artifactId>apache-httpcomponents-client-4-api</artifactId>
90-
<version>4.5.5-3.0</version>
9174
</dependency>
9275
<dependency>
9376
<groupId>org.slf4j</groupId>
9477
<artifactId>slf4j-api</artifactId>
95-
<version>${slf4jVersion}</version>
9678
<scope>provided</scope>
9779
</dependency>
9880
<dependency>
@@ -109,7 +91,6 @@
10991
<dependency>
11092
<groupId>org.jenkins-ci.plugins.workflow</groupId>
11193
<artifactId>workflow-job</artifactId>
112-
<version>2.9</version>
11394
<scope>test</scope>
11495
</dependency>
11596
</dependencies>

src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuildTrigger.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import org.kohsuke.stapler.DataBoundConstructor;
3636
import org.kohsuke.stapler.DataBoundSetter;
3737
import org.kohsuke.stapler.QueryParameter;
38-
import org.kohsuke.stapler.StaplerRequest;
38+
import org.kohsuke.stapler.StaplerRequest2;
3939
import stashpullrequestbuilder.stashpullrequestbuilder.stash.StashApiClient;
4040

4141
/** Created by Nathan McCarthy */
@@ -376,7 +376,7 @@ public String getDisplayName() {
376376
}
377377

378378
@Override
379-
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
379+
public boolean configure(StaplerRequest2 req, JSONObject json) throws FormException {
380380
enablePipelineSupport = false;
381381

382382
req.bindJSON(this, json);

src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashRepository.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public class StashRepository {
5252
private static final String BUILD_START_MESSAGE = "BuildStarted";
5353
private static final String BUILD_FINISH_MESSAGE = "BuildFinished";
5454
private static final String BUILD_CANCEL_MESSAGE = "BuildCanceled";
55-
private static final String[] BUILD_STATUSES = {BUILD_START_MESSAGE, BUILD_FINISH_MESSAGE, BUILD_CANCEL_MESSAGE};
55+
private static final String[] BUILD_STATUSES = {
56+
BUILD_START_MESSAGE, BUILD_FINISH_MESSAGE, BUILD_CANCEL_MESSAGE
57+
};
5658
private static final String BUILD_MARKER = "[*%s* **%s**] %s into %s";
5759

5860
private static final String BUILD_STATUS_REGEX =
@@ -259,8 +261,10 @@ private List<StashPullRequestBuildTarget> getBuildTargetsWithoutOnlyBuildOnComme
259261

260262
// These will match any start or finish message -- need to check commits
261263
String escapedBuildName = Pattern.quote(job.getDisplayName());
262-
String project_build_start = String.format(BUILD_STATUS_REGEX, BUILD_START_MESSAGE, escapedBuildName);
263-
String project_build_finished = String.format(BUILD_STATUS_REGEX, BUILD_FINISH_MESSAGE, escapedBuildName);
264+
String project_build_start =
265+
String.format(BUILD_STATUS_REGEX, BUILD_START_MESSAGE, escapedBuildName);
266+
String project_build_finished =
267+
String.format(BUILD_STATUS_REGEX, BUILD_FINISH_MESSAGE, escapedBuildName);
264268
Matcher startMatcher =
265269
Pattern.compile(project_build_start, Pattern.CASE_INSENSITIVE).matcher(content);
266270
Matcher finishMatcher =
@@ -331,7 +335,8 @@ private String postBuildStatusComment(
331335
throws StashApiException {
332336
String sourceCommit = pullRequest.getFromRef().getLatestCommit();
333337
String destinationCommit = pullRequest.getToRef().getLatestCommit();
334-
String comment = format(BUILD_MARKER, buildMessage, job.getDisplayName(), sourceCommit, destinationCommit);
338+
String comment =
339+
format(BUILD_MARKER, buildMessage, job.getDisplayName(), sourceCommit, destinationCommit);
335340
StashPullRequestComment commentResponse;
336341
commentResponse =
337342
this.client.postPullRequestComment(pullRequest.getId(), comment, buildCommandCommentId);
@@ -579,17 +584,12 @@ public void postFinishedComment(
579584
String message = getMessageForBuildResult(buildResult);
580585
String comment =
581586
format(
582-
BUILD_MARKER,
583-
BUILD_FINISH_MESSAGE,
584-
job.getDisplayName(),
585-
sourceCommit,
586-
destinationCommit)
587-
+ format(
588-
BUILD_FINISH_SENTENCE,
589-
message,
590-
buildUrl,
591-
buildNumber,
592-
duration);
587+
BUILD_MARKER,
588+
BUILD_FINISH_MESSAGE,
589+
job.getDisplayName(),
590+
sourceCommit,
591+
destinationCommit)
592+
+ format(BUILD_FINISH_SENTENCE, message, buildUrl, buildNumber, duration);
593593

594594
comment = comment.concat(additionalComment);
595595

@@ -684,7 +684,8 @@ private void deletePreviousBuildFinishedComments(StashPullRequestResponseValue p
684684
continue;
685685
}
686686

687-
String project_build_finished = format(BUILD_STATUS_REGEX, BUILD_FINISH_MESSAGE, job.getDisplayName());
687+
String project_build_finished =
688+
format(BUILD_STATUS_REGEX, BUILD_FINISH_MESSAGE, job.getDisplayName());
688689
Matcher finishMatcher =
689690
Pattern.compile(project_build_finished, Pattern.CASE_INSENSITIVE).matcher(content);
690691

src/test/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuildTriggerTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
import hudson.util.FormValidation;
1616
import hudson.util.FormValidation.Kind;
1717
import hudson.util.Secret;
18+
import jakarta.servlet.ServletContext;
19+
import jakarta.servlet.http.HttpServletRequest;
1820
import java.util.Arrays;
1921
import java.util.Collections;
20-
import javax.servlet.ServletContext;
21-
import javax.servlet.http.HttpServletRequest;
2222
import net.sf.json.JSONObject;
2323
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
2424
import org.junit.Rule;
@@ -27,7 +27,7 @@
2727
import org.jvnet.hudson.test.JenkinsRule;
2828
import org.kohsuke.stapler.RequestImpl;
2929
import org.kohsuke.stapler.Stapler;
30-
import org.kohsuke.stapler.StaplerRequest;
30+
import org.kohsuke.stapler.StaplerRequest2;
3131
import org.kohsuke.stapler.WebApp;
3232
import org.mockito.junit.MockitoJUnit;
3333
import org.mockito.junit.MockitoJUnitRunner;
@@ -48,7 +48,7 @@ public class StashBuildTriggerTest {
4848
@Rule public JenkinsRule jenkinsRule = new JenkinsRule();
4949
@Rule public MockitoRule rule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
5050

51-
private StaplerRequest makeStaplerRequest() {
51+
private StaplerRequest2 makeStaplerRequest() {
5252
ServletContext servletContext = mock(ServletContext.class);
5353
WebApp webApp = new WebApp(servletContext);
5454

@@ -64,7 +64,7 @@ private StaplerRequest makeStaplerRequest() {
6464
public void pipeline_jobs_not_supported_by_default() throws Exception {
6565
JSONObject json = new JSONObject();
6666

67-
StaplerRequest staplerRequest = makeStaplerRequest();
67+
StaplerRequest2 staplerRequest = makeStaplerRequest();
6868
descriptor.configure(staplerRequest, json);
6969

7070
FreeStyleProject project = jenkinsRule.createFreeStyleProject();
@@ -79,7 +79,7 @@ public void pipeline_jobs_not_supported_when_pipeline_support_disabled() throws
7979
JSONObject json = new JSONObject();
8080
json.put("enablePipelineSupport", "false");
8181

82-
StaplerRequest staplerRequest = makeStaplerRequest();
82+
StaplerRequest2 staplerRequest = makeStaplerRequest();
8383
descriptor.configure(staplerRequest, json);
8484

8585
FreeStyleProject project = jenkinsRule.createFreeStyleProject();
@@ -94,7 +94,7 @@ public void pipeline_jobs_supported_when_pipeline_support_enabled() throws Excep
9494
JSONObject json = new JSONObject();
9595
json.put("enablePipelineSupport", "true");
9696

97-
StaplerRequest staplerRequest = makeStaplerRequest();
97+
StaplerRequest2 staplerRequest = makeStaplerRequest();
9898
descriptor.configure(staplerRequest, json);
9999

100100
FreeStyleProject project = jenkinsRule.createFreeStyleProject();

0 commit comments

Comments
 (0)