Skip to content

Jenkins and GitHub integration

openaire-devs edited this page Jul 27, 2020 · 12 revisions

Overview

GitHub and Jenkins integration allows build status to be attached to a commit and viewed at GitHub. Jenkins build can be triggered by a push to existing branch, creation of new branch or new pull request.

NOTE: this description is valid as of Jenkins version Jenkins ver. 2.107.2 and should be revised at Jenkins update.

GitHub

  1. Create a new worker user at GitHub. This user will be used by Jenkins for checking out repositories and pushing commit's build status to GitHub.
  2. Generate a Personal Access Token for the worker user with repo:status access scope.
  3. Add worker user as a collaborator to project with Admin permission level.
  4. Make sure that there is a Jenkinsfile checked in the project. This file will be used to create a build configuration in Jenkins and should contain project build and test instructions. Use Jenkins Managed files functionality for providing any configuration settings valid for specific Jenkins instance.

Jenkins

  1. Create a credential entry of type/kind: Username with password with GitHub's worker user as username and worker user's Personal Access Token as the password. The credentials should be scoped at a level accessible for project's build configuration i.e. system or project. The type/kind of credentials is forced by GitHub Branch Source Plugin for Jenkins which supports only this type/kind of credentials.
  2. Create new Jenkins build configuration using Multibranch Pipeline template. Select GitHub as the branch sources and use the credentials for the worker user. This also allows to bypass GitHub's rate limit of 60 requests per hour, increasing this number to 5000 requests.
  3. In Build Configuration select by Jenkinsfile and set the path to Jenkinsfile within the repository to: jenkins/test/Jenkinsfile.
  4. Optionally configure other properties of the job, for example build triggers.
Clone this wiki locally