How to do it...

The steps are as follows:

  1. The GitHub Branch Source plugin comes preinstalled with the default installation, but if your setup does not already have the plugin, you can easily install it as we did in the previous recipe. Go to the Jenkins home page and proceed to Manage Jenkins, Manage Plugins, click on the Available tab and look for GitHub Branch Source. Install the plugin.
  1. Now, go back to the Jenkins homepage and click on Create New Jobs:
  1. Choose a job name and select GitHub Organization before clicking OK. The following configuration page can look a bit daunting, so let's break it down:
  1. The only section that really needs to be taken care of is Projects. The first thing to set is the GitHub credentials. This will allow Jenkins to automatically set up webhooks for us. Credentials in Jenkins are treated with security in mind and are properly encrypted, so don't be afraid to save them here.
  2. Next, we need to specify the Owner, which is simply the name of the GitHub organization we want to keep under control. The following section describes the behaviors, which are completely fine in their default form. They will allow building:
    • Branches
    • PRs coming from the repo itself
    • PRs coming from forks, but from trusted users

That is it! Now Jenkins will be able to automatically build any branch or PR as long as the code contains a Jenkinsfile. Jenkinsfiles are going to be treated in the next recipe, so stay tuned!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.253.152