Nick H.
Nick H.

Reputation: 1616

Jenkins Multibranch Pipeline - GitHub Enterprise Issues?

I have spent days troubleshooting/researching this issue. I can't seem to figure out what's going on here. I'm trying to setup a multibranch pipeline project pointed at our internal GitHub enterprise servers. The same issue occurs in other project types too like the "GitHub Organization". It's some sort of security issue that I can't figure out.

Let's start with what I know...

I have (to my knowledge) configured the GitHub Plugin configuration correctly with a TOKEN (also configured per documentation)... I can successfully "Verify Credentials" and it comes back successful. https://i.sstatic.net/Mg9Bv.jpg

I keep getting this validation issue on the GitHub Enterprise Servers Validation

https://i.sstatic.net/g9v27.jpg

I can connect successfully to any ONE repository hosted on my enterprise github server. When I try to configure a multi-branch project from a GitHub source, I ALWAYS get BLANK for repositories.... https://i.sstatic.net/IX52A.jpg

I configured a custom logger to see what was going on and it seems like the branch source plugin is always going out to api.github.com...

Jan 25, 2016 11:48:23 AM WARNING org.jenkinsci.plugins.github_branch_source.Endpoint$DesciptorImpl doCheckApiUri Jan 25, 2016 11:48:23 AM WARNING org.jenkinsci.plugins.github_branch_source.Endpoint$DesciptorImpl doCheckApiUri Jan 25, 2016 11:54:58 AM WARNING org.jenkinsci.plugins.github_branch_source.AbstractGitHubSCMSource$AbstractGitHubSCMSourceDescriptor doFillRepositoryItems Server returned HTTP response code: 401 for URL: https://api.github.com/user Jan 25, 2016 11:54:58 AM WARNING org.jenkinsci.plugins.github_branch_source.AbstractGitHubSCMSource$AbstractGitHubSCMSourceDescriptor doFillRepositoryItems Server returned HTTP response code: 401 for URL: https://api.github.com/orgs/nhudacin Jan 25, 2016 11:54:58 AM WARNING org.jenkinsci.plugins.github_branch_source.AbstractGitHubSCMSource$AbstractGitHubSCMSourceDescriptor doFillRepositoryItems Server returned HTTP response code: 401 for URL: https://api.github.com/users/nhudacin

I've configured the API endpoint for the GitHub plugin (as seen in the first screen shot), for the PR Builder plugin and the credentials are working (or so it seems). I'm thinkin it's a probably with the enterprise API endpoint configuration.

Any help?? I'm going CRAZY here!

Upvotes: 2

Views: 5376

Answers (2)

FedeN
FedeN

Reputation: 416

I'm having a similar issue as Nick H.

In my production Jenkins instance

  • Jenkins version 2.17 Latest weekly release with all plugins up to date as of Aug 10 i.e
    • GitHub Branch Source Plugin 1.8.1
    • PipelineMultibranch 2.8

I get :

WARNING: Server returned HTTP response code: -1, message: 'null' for URL: https://api.github.com/users/ORG

Even when I have configured the API endpoint on GitHub Enterprise Servers to be http://github.MYDOMAIN/api/v3/

On the other hand, on a fresh local install of Jenkins

with the same configuration I get:

Aug 11, 2016 3:19:14 PM org.jenkinsci.plugins.github_branch_source.GitHubSCMSource$DescriptorImpl doFillRepositoryItems

WARNING: Exception retrieving the repositories of the owner ORG on  with credentials USER/****** ( test credentials)

Edit: I found a way to make it work, it was not very intuitive, I found it after browsing the code and matching the strings to the plugin UI

What you need to do is, after you get the Invalid credentials red error press Advanced... button

enter image description here

Then a combo box with the API endpoints defined in the Manage Jenkins-> Configure System -> GitHub Enterprise Servers will appear.

enter image description here

Select the API endpoint for you GitHub Enterprise instance, choose Checkout credentials that have access to that instance and the list of all the repositories will appear.

Save it, and start a Branch indexing discovering the branches that have a JenkinsFile on it.

NOTE: in order to have this working every push a web hook needs to be installed in github Enterprise, you can do that by going

Manage Jenkins-> Configure System -> GitHub and press the second Advanced... button

enter image description here

Now a Re-register hook for all jobs button will appear. Just press that and it should add the hook that will be triggered every time you push into your matching repos.

Hope this helps

Upvotes: 1

Andrey Ershov
Andrey Ershov

Reputation: 1803

I don't have much knowledge about this particular scenario, but in this commit you can see, that they switched from regex validation to anonymous connection to endpoint. And if your server is in private mode, it will fail.

Upvotes: 0

Related Questions