GitHub Organization Repo + Jenkins Integration (GitHub Plugin)

I have an organization on GitHub with private repositories. I also have Jenkins configured on port 8080 on the server with the GitHub plugin installed. I created a GitHub account for my user jenkins, which is in the owners group.

I am trying to start working with jenkins when a change is pushed to my development branch (or leading branch, and does not seem to work).

When I look at GitHub Hook magazines in Jenkins, he says the poll is not running yet. When I go to Jenkins Management, the GitHub plugin says my account is verified when I test it.

Is it possible to understand how to configure this? I have several repositories that I would like to work with, so the deployment keys do not seem to me a solution.

+6
source share
3 answers

Update:

As Craig Ringer mentions in his answer , you can select Grant READ permissions for /github-webhook in the "Configuring Jenkins" section of the GitHub plugin settings, allowing the web move to invoke without authentication.

Another update: Web sites (December 2014) are now available for the organization : see the WebHooks API for Organizations .


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

 Last GitHub Push Polling has not run yet. 

And the conclusion was made:

Nevermind, the only missing part was the permission flag for the github user, which is not documented anywhere on the Internet.

So, is this a question about allowing your Jenkins users?

The article " Configuring Jenkins-CI on Ubuntu for painless testing of Rails3 CI applications " includes the following process:

To limit the CI system and provide access to your team members to use or view assembly logs, first create an account.

  • Go to Manage Jenkins > Configure System ,
  • Check Enable Security
  • In Security Realm select the Jenkins custom database
  • Check the Allow users to sign up box.
  • In Authorization select Project-based Matrix Authorization Strategy
  • Add the first user with the name admin and the other with GitHub (Note: the username for administrator access must be an administrator) For the GitHub username, just select the Read Only permission. Use this user later with GitHub.

Note. The admin and GitHub user added in this step does not create the user. Then you must create a real user with the same name. I know this is a little strange with the Jenkins user interface.

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

Github Web Hooking

Now, in order to automatically run the build when a new command or branch gets to Github, we need to set up the repository.

Go to the hook page for your repository. eg

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

In the AVAILABLE SERVICE HOOKS > Post-Receive URLs section, add github: github@your-ci-server.com /github-webhook/ .

github:github is a user created earlier.

Then we have to check out Jenkins with Github. Go to Jenkins> Configure System Management and under GitHub Web Hook, add your Github username and password and click the Test Credential button to log in once with Github.

+8
source

It seems that the accepted answer is no longer needed in the current version of the GitHub plugin. Instead, you can check the Grant READ permissions for /github-webhook in "Configure Jenkins" in the GitHub plugin settings so that the web host is called without authentication.

As explained in the help on this option, which is completely safe, and frankly, no worse than a user with the name "github" with the password "github" in any case.

+2
source

There are two ways to achieve automatic builds on Jenkins. What you choose depends on whether GitHub can call the URL of the Jenkins server that you provide. This may not be the case if you use Jenkins behind a firewall.

  • If GitHub can reach this URL, you can set up a service hook on your repo.
  • If you cannot configure Jenkins to poll periodically .

You can configure both options, but one solution is enough to make it work. I will always be the first, if possible, as this saves CPU and traffic resources.

In any case, you need the GitHub plugin for Jenkins .

Hope this helps.

0
source

Source: https://habr.com/ru/post/916324/


All Articles