Configure Jenkins For Github CI w/ 2FA

Eric H. picture Eric H. · May 2, 2017 · Viewed 10k times · Source

My Github account has two factor authorization (2fa) enabled. I want to integrate Jenkins with a few of my private repositories, but I cannot authorize them because I have 2fa enabled. Note this is a multibranch pipeline project.

Any ideas how to configure Jenkins to connect with private repos without creating a dummy account that does not have 2fa enabled? enter image description here

Answer

Eric H. picture Eric H. · May 2, 2017

Whoever would have thought to click the help button?

Credentials used to scan branches and pull requests, check out sources and mark commit statuses.

If none is given, only the public repositories will be scanned, and commit status will not be set on GitHub.

If your organization contains private repositories, then you need to specify a credential from an user who have access to those repositories.
This is done by creating a "username with password" credential where the password is GitHub personal access tokens. The necessary scope is "repo"

ie use a Github personal access token as your password when using username/password for your Jenkins credential.