如何在詹金斯中使用Github个人访问令牌 [英] How to use Github Personal Access Token in Jenkins
问题描述
我可以通过多种方式问这个问题,例如 如何使用Github个人访问令牌配置Jenkins凭据 如何使用Github个人访问令牌在Jenkins中克隆Github存储库
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
所以这就是问题
我知道的替代解决方案
-
SSH
连接
Jenkins中的 -
username
password
配置 但是我的问题是如何使用Personal Access Token
设置与Github的Github连接
SSH
connectionusername
password
configuration in Jenkins But My question is how to setup Github connection with Jenkins usingPersonal Access Token
推荐答案
在对Stackoverflow的多个线程进行了多次讨论之后
After many discussion on multiple threads from Stackoverflow
我发现一个有用的线程.
I found one thread which is useful.
请参阅以下答案: https://stackoverflow.com/a/61104603/5108695
基本上
至少就Jenkins
而言,Personal access token
可以用作密码.我向凭证管理器添加了新凭证.
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.
转到Jenkins
- 转到
credentials
>System
>Global credentials
>Add credentials
,将打开一个页面. - 在种类下拉列表中,选择用户名和密码.
- 在用户"中输入不存在的用户名,例如
jenkins-user
或user
. - 在密码字段中添加
Personal Access Token
- 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
oruser
. - Add
Personal Access Token
in the password field
现在开始配置您的项目.
Now start configuring your project.
- 源代码管理标签,从凭据附近的下拉菜单中选择新配置的凭据,位于存储库URL 下
- source code management tab, select new configured credentials from Drop-down near credential Under Repository URL
这就是我们可以使用个人访问令牌在Jenkins和Github之间配置或设置身份验证的方式
So this is how we can configure or setup Authentication between Jenkins and Github using Personal Access Token
参考文献:
Jenkins中的Git克隆永久禁用了个人访问令牌
更改jenkins管道以使用github而不是gitlab
References:
Git Clone in Jenkins with Personal Access Token idles forever
Change jenkins pipeline to use github instead of gitlab
这篇关于如何在詹金斯中使用Github个人访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!