Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

authentication - How to use Github Personal Access Token in Jenkins

I can ask this question in many ways, like How to configure Jenkins credentials with Github Personal Access Token How to clone Github repo in Jenkins using Github Personal Access Token

So this is the problem


The alternate solution that I am aware of

But My question is how to setup Github connection with Jenkins using Personal Access Token

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

[UPDATE] The new solution proposed by git is

https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/

Which says:

Beginning August 13, 2021, we will no longer accept account passwords when authenticating Git operations and will require the use of token-based authentication, such as a personal access token (for developers) or an OAuth or GitHub App installation token (for integrators) for all authenticated Git operations on GitHub.com. You may also continue using SSH keys where you prefer.

What you need to do:

https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/#what-you-need-to-do-today

Basically, change the add URL as

https://<access token>@github.com/<userName>/<repository>.git

Something like this

https://<access token>@github.com/dupinder/NgnixDockerizedDevEnv.git

and set the credentials to none.

Thanks to @Gil Stal


[OLD Technique]

After many discussion on multiple threads from Stackoverflow

I found one thread that is useful.

Refer to this answer: https://stackoverflow.com/a/61104603/5108695


Basically Personal access token can be used as a password, as far as Jenkins is concerned at least. I added new credentials to the credential manager.

Go to Jenkins

  • Go to credentials > System > Global credentials > Add credentials a page will open.
  • In Kind drop-down select Username and password.
  • In User put a non-existing username like jenkins-user or user.
  • Add Personal Access Token in the password field

Now start configuring your project.

  • source code management tab, select new configured credentials from Drop-down near credential Under Repository URL

So this is how we can configure or setup Authentication between Jenkins and Github using Personal Access Token

References:
Git Clone in Jenkins with Personal Access Token idles forever
Change jenkins pipeline to use github instead of gitlab


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...