The steps are as follows:
- Now, go back to the Jenkins homepage and click on Create New Jobs:
- 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:
- 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.
- 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!