-
Notifications
You must be signed in to change notification settings - Fork 11
Jenkins and GitHub integration
openaire-devs edited this page Jul 27, 2020
·
12 revisions
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.
- 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.
- Generate a Personal Access Token for the worker user with
repo:status
access scope. - Add worker user as a collaborator to project with
Admin
permission level. - 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 JenkinsManaged files
functionality for providing any configuration settings valid for specific Jenkins instance.
- 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 byGitHub Branch Source Plugin
for Jenkins which supports only this type/kind of credentials. - Create new Jenkins build configuration using
Multibranch Pipeline
template. SelectGitHub
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. - In Build Configuration select
by Jenkinsfile
and set the path to Jenkinsfile within the repository to:jenkins/test/Jenkinsfile
. - Optionally configure other properties of the job, for example build triggers.