18

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

Eric H.
  • 6,894
  • 8
  • 43
  • 62

1 Answers1

26

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.

Andrew J. Rech
  • 456
  • 4
  • 11
Eric H.
  • 6,894
  • 8
  • 43
  • 62
  • 3
    using the access token instead of the password doesn't work. – Mark Khateeb Aug 18 '17 at 10:46
  • Agreed with Mahmoud. Using a Personal Access Token does not seem to work as a password with 2FA enabled for the account. – Adam Link Feb 05 '18 at 16:38
  • 3
    Edit: The personal access token **does** work. However, if you select the token by double clicking on it in GH, it will add a `space` to the front of the token. Be sure you are not selecting whitespace inadvertently! – Adam Link Feb 05 '18 at 16:57
  • 2
    Multi-branch pipeline project does not allow you to setup GitHub source with personal token. It forces you to select account/password. It can not connect to the GitHub repo if your account is 2fa enabled. – c9s Nov 07 '18 at 08:57
  • Are there any guides on how to do this that work? I'm just trying to set Jenkins up locally - I keep on getting errors and I'm still not sure what approach I should be taking. The help text that you're referring to Andrew doesn't really explain the steps required. Having done extensive searching online and going through the Jenkins setup docs, some pointers to robust guidelines would be appreciated. Thanks – Matt Dec 05 '19 at 16:02