Skip to content

Conversation

@vanta
Copy link
Contributor

@vanta vanta commented Oct 21, 2025

Description

JENKINS-71749

When scanning the organization, repositories are obtained using search GH API. Results are paged by 100 items, in SR we have more repositories so the final result is the result of multiple paged calls. There is no sorting order set when repos are fetched, resulting in a best-match sorting (according to GH), which turned out to be not a stable sort - the same repository was returned twice or even three times on multiple pages, and other repositories were lost. As a result, we observed that jobs were disappearing on Jenkins in the Org Folder.

This PR adds stable sorting, based on the repository name, so no results are lost.

Submitter checklist

  • Link to JIRA ticket in description, if appropriate.
  • Change is code complete and matches issue description
  • Automated tests have been added to exercise the changes
  • Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.

Reviewer checklist

  • Run the changes and verify that the change matches the issue description
  • Reviewed the code
  • Verified that the appropriate tests have been written or valid explanation given

Documentation changes

  • Link to jenkins.io PR, or an explanation for why no doc changes are needed

Users/aliases to notify

Co-authored-by: Jesse Glick <[email protected]>
Co-authored-by: Carroll Chiou <[email protected]>
Co-authored-by: ARUS2023 <[email protected]>
Co-authored-by: Bruno Verachten <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: spotoczny <[email protected]>
Co-authored-by: Marcin Kasinski <[email protected]>
@vanta vanta requested a review from a team as a code owner October 21, 2025 07:45
@vanta vanta changed the title Fixed order when searching for repositories in GH organization fix: Add stable order when searching for repositories in GH organization Oct 21, 2025
@jtnord jtnord changed the title fix: Add stable order when searching for repositories in GH organization [JENKINS-71749] Add stable order when searching for repositories in GH organization Oct 23, 2025
@jtnord jtnord added the bug label Oct 23, 2025
Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems logical

Comment on lines +1140 to +1144
List<String> repoList = StreamSupport.stream(repositories.spliterator(), false)
.map(GHRepository::getName)
.collect(Collectors.toList());

String repoString = String.join(",", repoList);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT, slightly inefficient vs creating the string without the intermediate map (e.g. untested)

Suggested change
List<String> repoList = StreamSupport.stream(repositories.spliterator(), false)
.map(GHRepository::getName)
.collect(Collectors.toList());
String repoString = String.join(",", repoList);
String repoString = StreamSupport.stream(repositories.spliterator(), false)
.map(GHRepository::getName)
.collect(Collectors.joining(", "));

@jtnord jtnord merged commit 4cab2c6 into jenkinsci:master Oct 23, 2025
15 checks passed
@jtnord
Copy link
Member

jtnord commented Oct 24, 2025

Thank you for your contribution @vanta

@vanta vanta deleted the add-sorting branch October 25, 2025 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants