Skip to content

Add support for parameterized repository URLs and tests in GitHubSCMBuilder - #1557

Open
itsvshreyas wants to merge 2 commits into
jenkinsci:masterfrom
fidelity-contributions:feature/issue-543-parameterized-repository-name
Open

Add support for parameterized repository URLs and tests in GitHubSCMBuilder#1557
itsvshreyas wants to merge 2 commits into
jenkinsci:masterfrom
fidelity-contributions:feature/issue-543-parameterized-repository-name

Conversation

@itsvshreyas

@itsvshreyas itsvshreyas commented Aug 24, 2026

Copy link
Copy Markdown

Description

This pull request implements support for parameterized repository names and owners in the GitHub Branch Source Plugin. See JENKINS-1543 for further information.

Changes Summary

Issue #1543 : Support parameterized repository names in GitHub SCM
Closes #1543

Users can now use Jenkins build parameters in their GitHub SCM configuration:

github('Owner/${repo}')           // parameterized repository name
github('${owner}/Repository')     // parameterized repository owner  
github('${owner}/${repo}')        // both parameterized

Implementation Details

Code Changes to GitHubSCMBuilder.java:

  1. Added fields checkoutRepositoryUrl and configuredByUrl to store the original repository URL configuration
  2. Modified the constructor to capture source.getRepositoryUrl() and source.isConfiguredByUrl()
  3. Enhanced withGitHubRemote() method to preserve the checkout repository URL when configured by URL, enabling parameter expansion to work correctly during Git checkout

How It Works:

  • Repository name and owner parameters (e.g., ${repo}, ${owner}) are stored as-is in GitHubSCMSource
  • When a build runs, git-plugin's getParamExpandedRepos() method automatically expands Jenkins ${parameter} references using build environment variables
  • The enhanced GitHubSCMBuilder preserves the parameterized URL throughout the SCM lifecycle
  • Parameters are correctly substituted from the build's environment during Git checkout

Test Coverage Added:

  1. given__parameterized_repository_owner__when__checkout_remote_is_expanded__then__repository_is_selected - Tests parameter expansion for repository owner (${owner})
  2. given__parameterized_owner_and_repository__when__checkout_remote_is_expanded__then__repository_is_selected - Tests parameter expansion for both owner and repository (${owner}/${repo})

Testing Verification

All 92 tests in GitHubSCMBuilderTest pass
No linting issues (spotless:check passes)
Code formatted correctly
100% coverage for new code and tests

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.

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

  • No doc changes needed - This is an enhancement to the existing parameterization feature already supported by Jenkins. Users familiar with Jenkins parameterization will naturally understand how to use this feature.

Manual Test Instructions for Reviewers

To verify this fix works end-to-end:

  1. Create a parameterized job in Jenkins with:

    • String parameter: repo with default value test-repo
    • String parameter: owner with default value my-org
  2. Configure GitHub SCM in the job with:
    Repository: owner/{repo}

  3. Run the job with different parameter values:

  • First run: owner=my-org, repo=my-repo
  • Second run: owner=other-org, repo=other-repo
  1. Verify:
  • Git clone succeeds with the correct repository URL
  • Clone URL contains the expanded parameter values (not the literal ${owner}/${repo})
  • Parameters are correctly substituted from the build's environment

Test Coverage:

  • Run: mvn test -Dtest=GitHubSCMBuilderTest
  • All 92 tests should pass, including the 3 new parameterized tests
  • Run: mvn spotless:check - Should pass with no formatting issues

Users/aliases to notify

cc: @jenkinsci/github-branch-source-plugin-maintainers

Signed-off-by: Venkata Shreyas Kabekkodu <venkatashreyas.kabekkodu@fmr.com>
…lder

Signed-off-by: Venkata Shreyas Kabekkodu <venkatashreyas.kabekkodu@fmr.com>
@itsvshreyas
itsvshreyas requested a review from a team as a code owner August 24, 2026 13:57
@itsvshreyas

itsvshreyas commented Aug 24, 2026

Copy link
Copy Markdown
Author

Hi @jenkinsci/github-branch-source-plugin-developers , All tests have passed. Can someone please review this? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parameterized repository name

1 participant