Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub Organization Repo + Jenkins (GitHub Plugin) integration

I have an organization on GitHub with private repositories. I also have Jenkins set up running on port 8080 on a server, with the GitHub plugin installed. I've created an account on GitHub for my jenkins user, which resides in the owners group.

I'm trying to trigger a job on jenkins when a change is pushed to my development branch (or master branch, neither seem to be working).

When I look at the GitHub Hook Logs in Jenkins, it says that Polling has not run yet. When I go to "Manage Jenkins", the GitHub plugin says my account is Verified when I test it.

Any insight on how to configure this? I have multiple repositories I'd like to work with, so deploy keys don't seem like the solution to me.

like image 345
w2bro Avatar asked May 22 '12 05:05

w2bro


People also ask

How do I integrate my GitHub repository to my Jenkins project?

Step 1: go to your GitHub repository and click on 'Settings'. Step 2: Click on Webhooks and then click on 'Add webhook'. Step 3: In the 'Payload URL' field, paste your Jenkins environment URL. At the end of this URL add /github-webhook/.

Can we use GitHub plugin in Jenkins?

Build integration With the help of the Git plugin Jenkins can easily pull source code from any Git repository that the Jenkins build node can access. The GitHub plugin extends upon that integration further by providing improved bi-directional integration with GitHub.


1 Answers

Update:

As Craig Ringer mentions in his answer, you can select Grant READ permissions for /github-webhook in "Configure Jenkins" under the GitHub plugin settings, allowing the webhook to be called without authentication.

Another update: Webhooks are now (Dec. 2014) available for organization: see WebHooks API for orgs.


Note: the issue 4 of the hudson-github-plugin was about:

Last GitHub Push

Polling has not run yet.

And the conclusion was:

Nevermind, the only missing piece was a permission checkbox for the github user which ain't documented anywhere on the internet.

So is this a permission issue regarding your Jenkins users?

The article "Set up Jenkins-CI on Ubuntu for painless Rails3 app CI testing" includes the following process:

To restrict the CI system and give access to your Team members to use or see the build logs, first you’ve to create an account.

  • Go to Manage Jenkins > Configure System,
  • Check the Enable Security checkbox
  • Under Security Realm, choose Jenkins's own user database
  • Check the Allow users to sign up checkbox
  • Under Authorization, choose Project-based Matrix Authorization Strategy
  • Add first user with the name admin and another with GitHub (Note: the username for Admin access has to be admin) For GitHub named user, just choose the Overall Read only permission. We’ll use this user later with the GitHub hook.

Note: The admin and GitHub user that we’ve added in the above step does not create the User. Then you’ve to create a real user with that same name. Ya, I know, its a bit weird with Jenkins UI.

Go to Manage Jenkins > Manage Users > Create User. Create both admin and GitHub users.

Hooking with the Github web-hooks

Now to run the build automagically when new commit or branch gets pushed onto Github, we have to setup the repository.

Got to the hooks page for your repository. e.g.

github.com/<username>/<project_name>/admin/hooks

Under AVAILABLE SERVICE HOOKS > Post-Receive URLs, add github:[email protected]/github-webhook/.

The github:github is the user that we’d created earlier.

Then we have to verify Jenkins with Github. Go to Manage Jenkins > Configure System and under GitHub Web Hook, add your Github username and password and click the Test Credential button to authorize once with Github.

like image 115
VonC Avatar answered Nov 15 '22 08:11

VonC