Jenkins - Github 插件 - 使用个人访问令牌 post Aug13 更新不适用于 url 更改

Jenkins - Github Plugin - Using Personal Access Token post Aug13 update not working with url change

到目前为止,我们在 Jenkins 设置中使用了带有用户名和密码凭据的 Github 插件。

但是,在 8 月 13 日之后,它停止工作并出现错误 - stderr: remote: Support for password authentication was removed on August 13, 2021。请改用个人访问令牌。 远程:请参阅 https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ 了解更多信息。

根据

中提供的答案

我将URL修改为 https://<access token>@github.com/<userName>/<organization>/<repository>.git

但这不起作用。

我是否遗漏了任何步骤?

使用以下方法创建您的私有访问令牌URL

https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

之后,在 Jenkins Job 的 Source Code Management 部分下,以 https://access_Token_Number@github.com/<[= 格式提供 Git 存储库 URL 30=]>/yourRepoName.git

例如,如果 Repo 名称是 abc,组织是 test,令牌号是 12345678,那么 URL 看起来像

https://12345678@github.com/test/abc.git

截图:

这个方法解决了我的问题。

这不是要改变 URL。 Jenkins 明确表示它需要个人访问令牌 (PAT) 而不是 git 授权密码。

请使用以下 link 创建 PAT: [https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token][1]

然后转到 Jenkins -> Configure Job -> Source Code Management 并更改 Repository URL 如下: https://access_Token_Number@github.com//yourRepoName.git

  • Access Token Number:它是您将使用上面共享的 link

    生成的 PAT
  • 组织名称:您的存储库所在的全局名称

  • RepoName:配置 Jenkins 作业的存储库名称