Skip to content

GHE returning 404 when trying to fetch reference file for master branch #844

@suryatej16

Description

@suryatej16

Describe the bug
Due to the change introduced in #822, GHE v2.18 will return a 404 when you attempt to access api/v3/repos/:org/:repo/git/ref/heads/master instead of api/v3/repos/:org/:repo/git/refs/heads/master. This is causing the Jenkins Github Branch Source plugin to throw the following stacktrace:

java.io.FileNotFoundException: https://xxxxxxxxx/api/v3/repos/:org/:repo/git/ref/heads/master
	at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
	at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
	at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
	at org.kohsuke.github.GitHubHttpUrlConnectionClient$HttpURLConnectionResponseInfo.bodyStream(GitHubHttpUrlConnectionClient.java:197)
	at org.kohsuke.github.GitHubResponse$ResponseInfo.getBodyAsString(GitHubResponse.java:321)
	at org.kohsuke.github.GitHubResponse.parseBody(GitHubResponse.java:85)
	at org.kohsuke.github.Requester.lambda$fetch$1(Requester.java:71)
	at org.kohsuke.github.GitHubClient.createResponse(GitHubClient.java:420)
	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:374)
Caused: org.kohsuke.github.GHFileNotFoundException: https://xxxxxx/api/v3/repos/:org/:repo/git/ref/heads/master {"message":"Not Found","documentation_url":"https://developer.github.com/enterprise/2.18/v3"}
	at org.kohsuke.github.GitHubClient.interpretApiError(GitHubClient.java:451)
	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:382)
	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:326)
	at org.kohsuke.github.Requester.fetch(Requester.java:71)
	at org.kohsuke.github.GHRepository.getRef(GHRepository.java:1594)
	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:1602)
	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:582)
	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:98)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)

To Reproduce
Steps to reproduce the behavior:

  1. Run a curl -X GET https://<host>/api/v3/repos/:org/:repo/git/ref/heads/master against GHE v.2.18 and you'll get a 404 in response

Expected behavior
Should return the ref for master branch.

Desktop (please complete the following information):
Jenkins Github Branch Source plugin 2.8.0
GHE 2.18

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions