Skip to content

[JENKINS-75285] Make SSH repository URLs clickable in build summary#3925

Open
Anshul-target wants to merge 4 commits intojenkinsci:masterfrom
Anshul-target:JENKINS-75285-git-ssh-summary-link
Open

[JENKINS-75285] Make SSH repository URLs clickable in build summary#3925
Anshul-target wants to merge 4 commits intojenkinsci:masterfrom
Anshul-target:JENKINS-75285-git-ssh-summary-link

Conversation

@Anshul-target
Copy link

Description

Fixes SSH repository URLs not being clickable in the build summary page when a Git browser is configured.

Problem:
Currently, the build summary page only creates hyperlinks for repository URLs that start with http or https. SSH URLs (like git@github.com:user/repo.git) are displayed as plain text, making it difficult to quickly navigate to the repository web viewer.

Solution:
Added getRepositoryBrowserUrl() method to BuildData class that converts SSH URLs to their corresponding HTTP URLs using the configured Git browser. Updated summary.jelly template to use this method when creating hyperlinks.

Changes Made

  • Added getRepositoryBrowserUrl() method to BuildData.java to convert SSH URLs to browser URLs
  • Added getGitSCM() helper method to retrieve GitSCM configuration from the build
  • Updated summary.jelly to use browser URL for SSH repositories when available
  • Added unit tests to verify fallback behavior when no browser is configured

Testing done

Manual Testing:

  1. Created a Jenkins freestyle project with SSH URL: git@github.com:Anshul-target/NoteBackend
  2. Configured GitHub browser with URL: https://github.com/Anshul-target/NoteBackend/
  3. Ran the build successfully
  4. Verified the repository URL is now clickable in the build summary

Before (Bug):
Screenshot 2026-02-05 105405

After (Fixed):

Screenshot 2026-02-07 101015

Automated Testing:

  • Added unit tests in BuildDataTest.java to verify:
    • Null URL handling
    • Fallback behavior when no owning run exists
    • HTTPS URL handling
    • SSH URL handling
  • All existing tests pass
  • New tests pass locally

Test execution:

mvn clean test -Dtest=BuildDataTest
# All tests passed

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

Related Issues

 Make SSH repository URLs clickable in build summaryi
SSH repository URLs (like git@github.com:user/repo.git) were displayed
as plain text in the build summary page, while HTTPS URLs were clickable.
This made it difficult to quickly navigate to the repository from builds
using SSH URLs.

Added getRepositoryBrowserUrl() method to BuildData class that converts
SSH URLs to HTTP URLs using the configured Git browser. Updated the
summary.jelly template to use this method for creating hyperlinks.

When a Git browser is configured, SSH URLs are now converted to their
corresponding web viewer URLs and displayed as clickable links, matching
the existing behavior for HTTPS URLs. If no browser is configured, the
original URL is displayed as before.
@Anshul-target Anshul-target requested a review from a team as a code owner February 7, 2026 04:51
@github-actions github-actions bot added the tests Automated test addition or improvement label Feb 7, 2026
@MarkEWaite MarkEWaite requested a review from Copilot February 7, 2026 16:44
@MarkEWaite
Copy link
Contributor

I don't review pull requests that are not passing checks. You have a spotbugs warning that indicates you did not run mvn clean verify. Please review the contributing guide and assure that you are following its recommendations.

I am not yet persuaded that I'm willing to extend BuildData with the repository URL. BuildData has been a source of issues for retaining too much data.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make SSH Git repository URLs (e.g. git@github.com:org/repo.git) clickable in the Jenkins build summary by resolving them to an HTTP(S) repository browser URL when a Git browser is configured.

Changes:

  • Added BuildData#getRepositoryBrowserUrl(String) (and a helper SCM lookup) to provide an HTTP(S) link target for repositories.
  • Updated BuildData/summary.jelly to use the new helper when rendering repository links.
  • Added unit tests covering null and “no owning run” fallback behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/main/java/hudson/plugins/git/util/BuildData.java Adds a Jelly-facing helper to resolve repository URLs via configured Git browser and a GitSCM lookup helper.
src/main/resources/hudson/plugins/git/util/BuildData/summary.jelly Switches summary rendering to prefer a browser-derived HTTP(S) URL when available.
src/test/java/hudson/plugins/git/util/BuildDataTest.java Adds tests for null URL and fallback paths when no owning run is present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add @checkfornull annotations for nullability clarity
- Apply fix to both summary.jelly and index.jelly for consistency
- Add null safety check in getGitSCM method
- Remove basic unit tests - will rely on manual testing
@Anshul-target
Copy link
Author

Hi @MarkEWaite, please check my pr i have fixed the spotbugs issue

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

Labels

tests Automated test addition or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JENKINS-75285] Git summary hyperlink for ssh URLs

3 participants