Skip to content

Commit

Permalink
[JENKINS-644418] Add exponential backoff to BitBucket rate limit retr…
Browse files Browse the repository at this point in the history
…y loop

Configure Apache HTTP client to use an exponential backoff retry strategy
  • Loading branch information
nfalco79 committed Nov 27, 2024
1 parent a71d0e0 commit 5dc6181
Show file tree
Hide file tree
Showing 9 changed files with 346 additions and 521 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ work

# VSCode
.factorypath
META-INF/
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private static void createStatus(@NonNull Run<?, ?> build, @NonNull TaskListener

private static @CheckForNull BitbucketSCMSource findBitbucketSCMSource(Run<?, ?> build) {
SCMSource s = SCMSource.SourceByItem.findSource(build.getParent());
return s instanceof BitbucketSCMSource ? (BitbucketSCMSource) s : null;
return s instanceof BitbucketSCMSource scm ? scm : null;
}

private static void sendNotifications(BitbucketSCMSource source, Run<?, ?> build, TaskListener listener)
Expand Down Expand Up @@ -211,12 +211,11 @@ private static void sendNotifications(BitbucketSCMSource source, Run<?, ?> build

@CheckForNull
private static String getHash(@CheckForNull SCMRevision revision) {
if (revision instanceof PullRequestSCMRevision) {
// unwrap
revision = ((PullRequestSCMRevision) revision).getPull();
if (revision instanceof PullRequestSCMRevision prRevision) {

Check warning on line 214 in src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketBuildStatusNotifications.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 214 is only partially covered, one branch is missing
revision = prRevision.getPull();

Check warning on line 215 in src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketBuildStatusNotifications.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 215 is not covered by tests
}
if (revision instanceof AbstractGitSCMSource.SCMRevisionImpl) {
return ((AbstractGitSCMSource.SCMRevisionImpl) revision).getHash();
if (revision instanceof AbstractGitSCMSource.SCMRevisionImpl scmRevision) {

Check warning on line 217 in src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketBuildStatusNotifications.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 217 is only partially covered, one branch is missing
return scmRevision.getHash();
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package com.cloudbees.jenkins.plugins.bitbucket.api;

import com.fasterxml.jackson.annotation.JsonIgnore;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.commons.codec.digest.DigestUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
Expand Down Expand Up @@ -99,6 +100,20 @@ public BitbucketBuildStatus(String hash, String description, Status state, Strin
this.name = name;
}

/**
* Copy constructor.
*
* @param other from copy to.
*/
public BitbucketBuildStatus(@NonNull BitbucketBuildStatus other) {
this.hash = other.hash;
this.description = other.description;
this.state = other.state;
this.url = other.url;
this.key = other.key;
this.name = other.name;
}

Check warning on line 115 in src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketBuildStatus.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 108-115 are not covered by tests

public String getHash() {
return hash;
}
Expand Down
Loading

0 comments on commit 5dc6181

Please sign in to comment.