Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,15 @@
}
}

static void invalidate(@NonNull GitHub hub) {
ConnectionId connectionId = reverseLookup.get(hub);
if (connectionId == null) {
return;
}
connections.remove(connectionId);
reverseLookup.remove(hub);
}

Check warning on line 525 in src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 519-525 are not covered by tests

static List<DomainRequirement> githubDomainRequirements(String apiUri) {
return URIRequirementBuilder.fromUri(StringUtils.defaultIfEmpty(apiUri, GitHubServerConfig.GITHUB_URL))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,21 @@
}

String fullName = repoOwner + "/" + repository;
ghRepository = github.getRepository(fullName);
try {
ghRepository = github.getRepository(fullName);
} catch (HttpException e) {
if (e.getResponseCode() != HttpServletResponse.SC_UNAUTHORIZED) {
throw e;
}
LOGGER.fine(() -> "token seems to be rotated, retrying with fresh credentials");
Connector.invalidate(github);
GitHub retryGitHub = Connector.connect(apiUri, getCredentials(retrieveContext, true));
try {
ghRepository = retryGitHub.getRepository(fullName);
} finally {
Connector.release(retryGitHub);
}
}

Check warning on line 1438 in src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 1426-1438 are not covered by tests
final GHRepository ghRepository = this.ghRepository;
listener.getLogger()
.format(
Expand Down
Loading