From 78891e939d0f800f4f4d4072d8360fee94a4bf7a Mon Sep 17 00:00:00 2001 From: Andrey Fomin Date: Wed, 28 Feb 2024 16:10:49 +0300 Subject: [PATCH] Fix backward compatibility of PullRequestSCMRevision Method `getPull` is used in some private plugins. #796 changed signature of this method. Now signature is returned back. See also #817. --- .../jenkins/plugins/bitbucket/BitbucketGitSCMBuilder.java | 6 ++++-- .../jenkins/plugins/bitbucket/PullRequestSCMRevision.java | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilder.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilder.java index 877d1f4f0..fa32fb1c9 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilder.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilder.java @@ -39,6 +39,7 @@ import hudson.plugins.git.GitSCM; import hudson.plugins.git.browser.BitbucketWeb; import java.util.List; +import jenkins.plugins.git.AbstractGitSCMSource; import jenkins.plugins.git.GitSCMBuilder; import jenkins.scm.api.SCMHead; import jenkins.scm.api.SCMRevision; @@ -223,14 +224,15 @@ private void withPullRequestRemote(PullRequestSCMHead head, String headName) { String primaryRemoteName = remoteName().equals("primary") ? "primary-primary" : "primary"; String cloneLink = getCloneLink(primaryCloneLinks); List branchWithHashes; + AbstractGitSCMSource.SCMRevisionImpl pullRevision = (AbstractGitSCMSource.SCMRevisionImpl) pullRequestSCMRevision.getPull(); if (checkoutStrategy == ChangeRequestCheckoutStrategy.MERGE) { branchWithHashes = List.of( - new BranchWithHash(branchName, pullRequestSCMRevision.getPull().getHash()), + new BranchWithHash(branchName, pullRevision.getHash()), new BranchWithHash(targetBranch, pullRequestSCMRevision.getTargetImpl().getHash()) ); } else { branchWithHashes = List.of( - new BranchWithHash(branchName, pullRequestSCMRevision.getPull().getHash()) + new BranchWithHash(branchName, pullRevision.getHash()) ); } withExtension(new FallbackToOtherRepositoryGitSCMExtension(cloneLink, primaryRemoteName, branchWithHashes)); diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/PullRequestSCMRevision.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/PullRequestSCMRevision.java index 7831f1269..9eb60ba1c 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/PullRequestSCMRevision.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/PullRequestSCMRevision.java @@ -26,6 +26,7 @@ import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.plugins.git.AbstractGitSCMSource; +import jenkins.scm.api.SCMRevision; import jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy; import jenkins.scm.api.mixin.ChangeRequestSCMRevision; @@ -65,7 +66,7 @@ public PullRequestSCMRevision(@NonNull PullRequestSCMHead head, @NonNull Abstrac * @return the pull revision. */ @NonNull - public AbstractGitSCMSource.SCMRevisionImpl getPull() { + public SCMRevision getPull() { return pull; }