@@ -439,8 +439,8 @@ private void retrievePullRequests(final BitbucketSCMSourceRequest request) throw
439439 class Skip extends IOException {
440440 }
441441
442- final BitbucketApi originBitbucket = buildBitbucketClient ();
443- if (request .isSkipPublicPRs () && !originBitbucket .isPrivate ()) {
442+ final BitbucketApi originClient = buildBitbucketClient ();
443+ if (request .isSkipPublicPRs () && !originClient .isPrivate ()) {
444444 request .listener ().getLogger ().printf ("Skipping pull requests for %s (public repository)%n" , fullName );
445445 return ;
446446 }
@@ -460,15 +460,15 @@ class Skip extends IOException {
460460 boolean fork = !StringUtils .equalsIgnoreCase (fullName , pull .getSource ().getRepository ().getFullName ());
461461 String pullRepoOwner = pull .getSource ().getRepository ().getOwnerName ();
462462 String pullRepository = pull .getSource ().getRepository ().getRepositoryName ();
463- final BitbucketApi client = fork && BitbucketApiUtils .isCloud (originBitbucket )
463+ final BitbucketApi client = fork && BitbucketApiUtils .isCloud (originClient )
464464 ? BitbucketApiFactory .newInstance (
465465 getServerUrl (),
466466 authenticator (),
467467 pullRepoOwner ,
468468 null ,
469469 pullRepository
470470 )
471- : originBitbucket ;
471+ : originClient ;
472472 count ++;
473473 livePRs .add (pull .getId ());
474474 getPullRequestTitleCache ()
@@ -507,7 +507,7 @@ public SCMRevision create(@NonNull SCMHead head, @Nullable BitbucketCommit sourc
507507 BranchHeadCommit targetCommit = new BranchHeadCommit (pull .getDestination ().getBranch ());
508508 return super .create (head , sourceCommit , targetCommit );
509509 } catch (BitbucketRequestException e ) {
510- if (originBitbucket instanceof BitbucketCloudApiClient ) {
510+ if (BitbucketApiUtils . isCloud ( originClient ) ) {
511511 if (e .getHttpCode () == 403 ) {
512512 request .listener ().getLogger ().printf ( //
513513 "Skipping %s because of %s%n" , //
@@ -555,15 +555,15 @@ private void retrieveBranches(final BitbucketSCMSourceRequest request)
555555 String fullName = repoOwner + "/" + repository ;
556556 request .listener ().getLogger ().println ("Looking up " + fullName + " for branches" );
557557
558- final BitbucketApi bitbucket = buildBitbucketClient ();
558+ final BitbucketApi client = buildBitbucketClient ();
559559 int count = 0 ;
560560 for (final BitbucketBranch branch : request .getBranches ()) {
561561 request .listener ().getLogger ().println ("Checking branch " + branch .getName () + " from " + fullName );
562562 count ++;
563563 if (request .process (new BranchSCMHead (branch .getName ()), //
564564 (IntermediateLambda <BitbucketCommit >) () -> new BranchHeadCommit (branch ), //
565- new BitbucketProbeFactory <>(bitbucket , request ), //
566- new BitbucketRevisionFactory <>(bitbucket ), //
565+ new BitbucketProbeFactory <>(client , request ), //
566+ new BitbucketRevisionFactory <>(client ), //
567567 new CriteriaWitness (request ))) {
568568 request .listener ().getLogger ().format ("%n %d branches were processed (query completed)%n" , count );
569569 return ;
@@ -596,16 +596,16 @@ private void retrieveTags(final BitbucketSCMSourceRequest request) throws IOExce
596596
597597 @ Override
598598 protected SCMRevision retrieve (SCMHead head , TaskListener listener ) throws IOException , InterruptedException {
599- final BitbucketApi bitbucket = buildBitbucketClient ();
599+ final BitbucketApi client = buildBitbucketClient ();
600600 try {
601601 if (head instanceof PullRequestSCMHead prHead ) {
602602 BitbucketCommit sourceRevision ;
603603 BitbucketCommit targetRevision ;
604604
605- if (bitbucket instanceof BitbucketCloudApiClient ) {
605+ if (BitbucketApiUtils . isCloud ( client ) ) {
606606 // Bitbucket Cloud /pullrequests/{id} API endpoint only returns short commit IDs of the source
607607 // and target branch. We therefore retrieve the branches directly
608- BitbucketBranch targetBranch = bitbucket .getBranch (prHead .getTarget ().getName ());
608+ BitbucketBranch targetBranch = client .getBranch (prHead .getTarget ().getName ());
609609
610610 if (targetBranch == null ) {
611611 listener .getLogger ().format ("No branch found in {0}/{1} with name [{2}]" ,
@@ -623,7 +623,7 @@ protected SCMRevision retrieve(SCMHead head, TaskListener listener) throws IOExc
623623 // Retrieve the source branch commit
624624 BitbucketBranch branch ;
625625 if (head .getOrigin () == SCMHeadOrigin .DEFAULT ) {
626- branch = bitbucket .getBranch (prHead .getBranchName ());
626+ branch = client .getBranch (prHead .getBranchName ());
627627 } else {
628628 // In case of a forked branch, retrieve the branch as that owner
629629 branch = buildBitbucketClient (prHead ).getBranch (prHead .getBranchName ());
@@ -640,7 +640,7 @@ protected SCMRevision retrieve(SCMHead head, TaskListener listener) throws IOExc
640640 } else {
641641 BitbucketPullRequest pr ;
642642 try {
643- pr = bitbucket .getPullRequestById (Integer .parseInt (prHead .getId ()));
643+ pr = client .getPullRequestById (Integer .parseInt (prHead .getId ()));
644644 } catch (NumberFormatException nfe ) {
645645 LOGGER .log (Level .WARNING , "Cannot parse the PR id {0}" , prHead .getId ());
646646 return null ;
@@ -672,7 +672,7 @@ protected SCMRevision retrieve(SCMHead head, TaskListener listener) throws IOExc
672672 new BitbucketGitSCMRevision (prHead , sourceRevision )
673673 );
674674 } else if (head instanceof BitbucketTagSCMHead tagHead ) {
675- BitbucketBranch tag = bitbucket .getTag (tagHead .getName ());
675+ BitbucketBranch tag = client .getTag (tagHead .getName ());
676676 if (tag == null ) {
677677 listener .getLogger ().format ( "No tag found in {0}/{1} with name [{2}]" ,
678678 repoOwner , repository , head .getName ());
@@ -686,7 +686,7 @@ protected SCMRevision retrieve(SCMHead head, TaskListener listener) throws IOExc
686686 }
687687 return new BitbucketTagSCMRevision (tagHead , revision );
688688 } else {
689- BitbucketBranch branch = bitbucket .getBranch (head .getName ());
689+ BitbucketBranch branch = client .getBranch (head .getName ());
690690 if (branch == null ) {
691691 listener .getLogger ().format ("No branch found in {0}/{1} with name [{2}]" ,
692692 repoOwner , repository , head .getName ());
@@ -1093,8 +1093,9 @@ private List<BitbucketHref> getCloneLinksFromPrimary(BitbucketApi bitbucket) thr
10931093 return cloneLinksLocal ;
10941094 }
10951095
1096+ @ Deprecated (since = "936.0.0" , forRemoval = true )
10961097 public boolean isCloud () {
1097- return BitbucketCloudEndpoint . SERVER_URL . equals (serverUrl );
1098+ return BitbucketApiUtils . isCloud (serverUrl );
10981099 }
10991100
11001101 @ Symbol ("bitbucket" )
0 commit comments