- How to integrate GitHub (and/or GitHub Enterprise) with Jenkins.
- I would like to trigger Jenkins jobs from GitHub (and/or GitHub Enterprise) from a “GitHub API User” (GitHub User to interact with Jenkins).
- CloudBees Jenkins Enterprise - Managed Master (CJE-MM)
- CloudBees Jenkins Team (CJT)
- CloudBees Jenkins Platform - Client Master (CJP-CM)
- DEV@cloud (D@C)
- Jenkins LTS
A. Plugin configuration
Go to Manage Jenkins > Configure System > GitHub section > Add a new Github Server Config
Add GitHub server/s managed by this Jenkins instance. So, if your Jenkins instance uses multiple repositories that are spread across different user accounts, you can list them all here as separate configs.
A.1 `API URL`
- GitHub leave default
- GitHub Enterprise change the
API URLby its API endpoint (e.g. For “https://ghe.acme.com” and API version 3: "https://ghe.acme.com/api/v3/").
- You need Credentials for each of the GitHub/GitHub Enterprise Server added here.
- Jenkins needs a Personal API token to interact with the GitHub via webhooks.
- Credentials from User:
Adminpermissions are required at the repository level but
Ownerrole is required to create it at Organization level; For updating commit statuses / reading the list of collaborators,
Writepermission is required.
Secret Text - API Token (recommended)
Secret: GitHub API token for “GitHub-API-User” as explained in
Option 2: GitHub
Username and Password - Letting the GitHub plugin to get API token for you.
Username and Password
- Go to Advanced > Manage Additional GitHub Actions > Convert Login and Password to token
- LIMITATION: Auto-creating token doesn’t work with GitHub 2FA.
Credentials can be validated by clicking on
Test Connection. If the credentials are correct a similar output to the following is expected:
Verify credentials Credentials verified for user "GitHub-API-User", rate limit: 4994
Pay attention to the “GitHub API User” Rate limits
A.3 `Manage hooks`
Automatic Mode (Recommended)
Manage hooks: enabled
Jenkins create hooks in GitHub for you.
Manage hooks: disabled
IMPORTANT: In this mode, you’ll be responsible for creating the webhook in GitHub under the following premises
- Payload URL, events and location (repository vs organization) must match with Validate GitHub WebHook section in GitHub Webhook: Non-Multibranch Jobs, GitHub Webhook: Pipeline Multibranch, GitHub Webhook: Organization Folder depending on the case.
- Content type should be set up as
application/x-www-form-urlencodedfor PR events in Freestyle Jobs)
B. Job Configuration
IMPORTANT: We recommend Multibranch Pipeline Jobs or GitHub Organization Folders.
Depending of the type of jobs:
B.1 Non-Multibranch Jobs
B.2 Pipeline Multibranch
B.3 Github Organization Folder
Tested products/plugins version
The latest update of this article was tested with: