jenkinsci / ghprb-plugin

github pull requests builder plugin for Jenkins
https://plugins.jenkins.io/ghprb/
MIT License
506 stars 612 forks source link

GHPRB incorrectly handles some types of SSH URL #766

Open cowlinator opened 4 years ago

cowlinator commented 4 years ago

CompareCoverageAction incorrectly handles some types of SSH URL.

For example, valid ssh URLs come in 2 flavors:

Anyway, when passing the git URL as an argument to CompareCoverageAction, the URL argument eventually makes its way to GitUtils.getUserRepo. This function uses one of 2 regex patterns: HTTP_GITHUB_USER_REPO_PATTERN or SSH_GITHUB_USER_REPO_PATTERN.

SSH_GITHUB_USER_REPO_PATTERN only accounts for the 1st flavor of ssh URL.

This is a problem, and GitUtils.getUserRepo should be able to handle urls in the ssh://user@domain/path format.

If this cannot be fixed, please at least document it.

Here is my repro case:

[$class: 'CompareCoverageAction', publishResultAs: 'statusCheck', scmVars: [GIT_URL: "ssh://git@github.myCompany.com/Organization/Repo"]]

Actual result:

Caused: java.io.IOException: Could not retrieve GitHub repository named //git@github.myCompany.com/Organization/Repo (Do you have properly set 'GitHub project' field in job configuration?)

Expected result: The plugin correctly gets the repo and completes the code coverage