diff --git a/pom.xml b/pom.xml index 9c0af64a..0c66adb5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,8 @@ org.jenkins-ci.plugins plugin - 3.53 + 5.7 + stash-pullrequest-builder @@ -15,26 +16,8 @@ This plugin builds Stash pull requests and posts the build results on Stash https://github.com/jenkinsci/stash-pullrequest-builder-plugin - - - nemccarthy - Nathan McCarthy - nem@nemccarthy.me - - - jimklimov - Jim Klimov - jimklimov@gmail.com - - - jbochenski - Jakub Bocheński - kuba.bochenski+stash-pullrequest-builder-plugin@gmail.com - - - - scm:git:ssh://github.com/jenkinsci/stash-pullrequest-builder-plugin.git + scm:git:https://github.com/jenkinsci/stash-pullrequest-builder-plugin.git scm:git:ssh://git@github.com/jenkinsci/stash-pullrequest-builder-plugin.git ${scmTag} https://github.com/jenkinsci/stash-pullrequest-builder-plugin @@ -56,8 +39,10 @@ 1.18 -SNAPSHOT - 8 - 2.60.3 + + 2.479 + ${jenkins.baseline}.1 + 1.7.25 Max Low @@ -65,10 +50,11 @@ - junit - junit - 4.13 - test + io.jenkins.tools.bom + bom-${jenkins.baseline}.x + 4136.vca_c3202a_7fd1 + pom + import @@ -77,22 +63,18 @@ org.jenkins-ci.plugins jackson2-api - 2.9.9.1 org.jenkins-ci.plugins credentials - 2.1.5 org.jenkins-ci.plugins apache-httpcomponents-client-4-api - 4.5.5-3.0 org.slf4j slf4j-api - ${slf4jVersion} provided @@ -109,7 +91,6 @@ org.jenkins-ci.plugins.workflow workflow-job - 2.9 test diff --git a/src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuildTrigger.java b/src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuildTrigger.java index 0d51d692..322d97ec 100644 --- a/src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuildTrigger.java +++ b/src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuildTrigger.java @@ -35,7 +35,7 @@ import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; import org.kohsuke.stapler.QueryParameter; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; import stashpullrequestbuilder.stashpullrequestbuilder.stash.StashApiClient; /** Created by Nathan McCarthy */ @@ -376,7 +376,7 @@ public String getDisplayName() { } @Override - public boolean configure(StaplerRequest req, JSONObject json) throws FormException { + public boolean configure(StaplerRequest2 req, JSONObject json) throws FormException { enablePipelineSupport = false; req.bindJSON(this, json); diff --git a/src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashRepository.java b/src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashRepository.java index 14dbcf81..24232ef3 100644 --- a/src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashRepository.java +++ b/src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashRepository.java @@ -52,7 +52,9 @@ public class StashRepository { private static final String BUILD_START_MESSAGE = "BuildStarted"; private static final String BUILD_FINISH_MESSAGE = "BuildFinished"; private static final String BUILD_CANCEL_MESSAGE = "BuildCanceled"; - private static final String[] BUILD_STATUSES = {BUILD_START_MESSAGE, BUILD_FINISH_MESSAGE, BUILD_CANCEL_MESSAGE}; + private static final String[] BUILD_STATUSES = { + BUILD_START_MESSAGE, BUILD_FINISH_MESSAGE, BUILD_CANCEL_MESSAGE + }; private static final String BUILD_MARKER = "[*%s* **%s**] %s into %s"; private static final String BUILD_STATUS_REGEX = @@ -259,8 +261,10 @@ private List getBuildTargetsWithoutOnlyBuildOnComme // These will match any start or finish message -- need to check commits String escapedBuildName = Pattern.quote(job.getDisplayName()); - String project_build_start = String.format(BUILD_STATUS_REGEX, BUILD_START_MESSAGE, escapedBuildName); - String project_build_finished = String.format(BUILD_STATUS_REGEX, BUILD_FINISH_MESSAGE, escapedBuildName); + String project_build_start = + String.format(BUILD_STATUS_REGEX, BUILD_START_MESSAGE, escapedBuildName); + String project_build_finished = + String.format(BUILD_STATUS_REGEX, BUILD_FINISH_MESSAGE, escapedBuildName); Matcher startMatcher = Pattern.compile(project_build_start, Pattern.CASE_INSENSITIVE).matcher(content); Matcher finishMatcher = @@ -331,7 +335,8 @@ private String postBuildStatusComment( throws StashApiException { String sourceCommit = pullRequest.getFromRef().getLatestCommit(); String destinationCommit = pullRequest.getToRef().getLatestCommit(); - String comment = format(BUILD_MARKER, buildMessage, job.getDisplayName(), sourceCommit, destinationCommit); + String comment = + format(BUILD_MARKER, buildMessage, job.getDisplayName(), sourceCommit, destinationCommit); StashPullRequestComment commentResponse; commentResponse = this.client.postPullRequestComment(pullRequest.getId(), comment, buildCommandCommentId); @@ -579,17 +584,12 @@ public void postFinishedComment( String message = getMessageForBuildResult(buildResult); String comment = format( - BUILD_MARKER, - BUILD_FINISH_MESSAGE, - job.getDisplayName(), - sourceCommit, - destinationCommit) - + format( - BUILD_FINISH_SENTENCE, - message, - buildUrl, - buildNumber, - duration); + BUILD_MARKER, + BUILD_FINISH_MESSAGE, + job.getDisplayName(), + sourceCommit, + destinationCommit) + + format(BUILD_FINISH_SENTENCE, message, buildUrl, buildNumber, duration); comment = comment.concat(additionalComment); @@ -684,7 +684,8 @@ private void deletePreviousBuildFinishedComments(StashPullRequestResponseValue p continue; } - String project_build_finished = format(BUILD_STATUS_REGEX, BUILD_FINISH_MESSAGE, job.getDisplayName()); + String project_build_finished = + format(BUILD_STATUS_REGEX, BUILD_FINISH_MESSAGE, job.getDisplayName()); Matcher finishMatcher = Pattern.compile(project_build_finished, Pattern.CASE_INSENSITIVE).matcher(content); diff --git a/src/test/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuildTriggerTest.java b/src/test/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuildTriggerTest.java index 01671596..117168c1 100644 --- a/src/test/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuildTriggerTest.java +++ b/src/test/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuildTriggerTest.java @@ -15,10 +15,10 @@ import hudson.util.FormValidation; import hudson.util.FormValidation.Kind; import hudson.util.Secret; +import jakarta.servlet.ServletContext; +import jakarta.servlet.http.HttpServletRequest; import java.util.Arrays; import java.util.Collections; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; import net.sf.json.JSONObject; import org.jenkinsci.plugins.workflow.job.WorkflowJob; import org.junit.Rule; @@ -27,7 +27,7 @@ import org.jvnet.hudson.test.JenkinsRule; import org.kohsuke.stapler.RequestImpl; import org.kohsuke.stapler.Stapler; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; import org.kohsuke.stapler.WebApp; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoJUnitRunner; @@ -48,7 +48,7 @@ public class StashBuildTriggerTest { @Rule public JenkinsRule jenkinsRule = new JenkinsRule(); @Rule public MockitoRule rule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS); - private StaplerRequest makeStaplerRequest() { + private StaplerRequest2 makeStaplerRequest() { ServletContext servletContext = mock(ServletContext.class); WebApp webApp = new WebApp(servletContext); @@ -64,7 +64,7 @@ private StaplerRequest makeStaplerRequest() { public void pipeline_jobs_not_supported_by_default() throws Exception { JSONObject json = new JSONObject(); - StaplerRequest staplerRequest = makeStaplerRequest(); + StaplerRequest2 staplerRequest = makeStaplerRequest(); descriptor.configure(staplerRequest, json); FreeStyleProject project = jenkinsRule.createFreeStyleProject(); @@ -79,7 +79,7 @@ public void pipeline_jobs_not_supported_when_pipeline_support_disabled() throws JSONObject json = new JSONObject(); json.put("enablePipelineSupport", "false"); - StaplerRequest staplerRequest = makeStaplerRequest(); + StaplerRequest2 staplerRequest = makeStaplerRequest(); descriptor.configure(staplerRequest, json); FreeStyleProject project = jenkinsRule.createFreeStyleProject(); @@ -94,7 +94,7 @@ public void pipeline_jobs_supported_when_pipeline_support_enabled() throws Excep JSONObject json = new JSONObject(); json.put("enablePipelineSupport", "true"); - StaplerRequest staplerRequest = makeStaplerRequest(); + StaplerRequest2 staplerRequest = makeStaplerRequest(); descriptor.configure(staplerRequest, json); FreeStyleProject project = jenkinsRule.createFreeStyleProject();