GitUtils#getUserRepo logic is very strictive
Closed this issue · 3 comments
While working with this plugin on jenkins, I found that one of its key logic, GitUtils#getUserRepo
has unrealistic assumptions on the git url, in its regex matching:
For my working repository, the GIT_URL
set by the Github Plugin is https://github.com/apache/kafka/
which cause the github retrieve to fail:
https://github.com/kohsuke/github-api/blob/master/src/main/java/org/kohsuke/github/GitHub.java#L443
And here is the stack trace, note that the parsed repoName is //github.com/apache/kafka
not the expected apache/kafka
.
20:21:24 java.io.FileNotFoundException: https://api.github.com/repos//
20:21:24 at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1890)
...
20:21:24 Caused: java.io.IOException: Could not retrieve GitHub repository named //github.com/apache/kafka (Do you have properly set 'GitHub project' field in job configuration?)
20:21:24 at com.github.terma.jenkins.githubprcoveragestatus.GitHubPullRequestRepository.getGitHubRepository(GitHubPullRequestRepository.java:59)
20:21:24 at com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction.perform(CompareCoverageAction.java:98)
20:21:24 at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
20:21:24 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
20:21:24 at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
20:21:24 at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
20:21:24 at hudson.model.Build$BuildExecution.post2(Build.java:186)
20:21:24 at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
20:21:24 at hudson.model.Run.execute(Run.java:1749)
20:21:24 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
20:21:24 at hudson.model.ResourceController.execute(ResourceController.java:97)
20:21:24 at hudson.model.Executor.run(Executor.java:421)
As a reference, this is the configuration job that I'm experimenting:
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/configure
@guozhangwang could you please add configuration as doc. Don't have access to apache builds.
Just tried to use GitUtils.getUserRepo(...)
all works fine, it returns apache/kafka
You can try it too by adding your case to https://github.com/jenkinsci/github-pr-coverage-status-plugin/blob/ea26fb22ad13e6a310f614dc503fcd4218ea5c50/src/test/java/com/github/terma/jenkins/githubprcoveragestatus/GitUtilsTest.java
I can confirm it works fine by testing it on my local branch. Closing it now.