相关疑难解决方法(0)

如何在 Jenkins 中使用 Github 个人访问令牌

我可以通过多种方式提出这个问题,例如如何使用 Github 个人访问令牌配置 Jenkins 凭据如何使用 Github 个人访问令牌在 Jenkins 中克隆 Github 存储库

所以这就是问题所在


我知道的替代解决方案

但我的问题是如何使用 Jenkins 设置 Github 连接 Personal Access Token

authentication github jenkins jenkins-github-plugin

25
推荐指数
2
解决办法
3万
查看次数

Jenkins 中带有个人访问令牌的 Git 克隆永远空闲

我们有一个企业github运行在公司网络之外的远程github服务器上,需要使用https代理来克隆。我们不允许使用密码身份验证,因此要么使用 ssh(由于代理问题而无法使用)或 PAT。

在我的命令行上,命令

git clone https://user:token@github.exampleco.com/org/repo.git
Run Code Online (Sandbox Code Playgroud)

克隆存储库没有问题,大约需要 5-10 秒。

在 Jenkins 中,控制台输出显示“克隆到目录名称”,然后有一个旋转轮无休止地旋转,并且永远无法解决。

我在执行 shell 脚本中运行它,因为 github 插件运行一些命令,显然仍然想要进行密码身份验证,即使我向它提供没有凭据的 PAT 版本的 url,并且我没有看到 PAT 授权选项在添加凭据模式中。

为了澄清给 Jenkins 插件的 url 是:

https://user:token@github.exampleco.com/org/repo.git
Run Code Online (Sandbox Code Playgroud)

我得到这样的输出:

No credentials specified
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://user:token@github.exampleco.com/org/repo.git # timeout=10
Fetching upstream changes from https://user@github.exampleco.com/org/repo.git
 > git --version # timeout=10
Setting http proxy: corporateproxy.com:8080
 > git fetch --tags --progress https://user@github.exampleco.com/org/repo.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin' …
Run Code Online (Sandbox Code Playgroud)

git jenkins

2
推荐指数
1
解决办法
2万
查看次数