【问题标题】:Temporary store git credentials in credential-cache在凭据缓存中临时存储 git 凭据
【发布时间】:2019-10-04 13:24:03
【问题描述】:

我在 Carthage、GitLab CI 和我们的内部依赖项方面遇到了一些身份验证问题。 我们的跑步者很干净,出于安全原因,他们的钥匙串中没有存储 GitLab 的任何凭据。

carthage bootstrap 在作业中运行时,Carthage 使用git credential fill 来验证请求,在我们的例子中它失败了。

A shell task (/usr/bin/env git fetch --prune --quiet https://gitlab.corp.com/path/to/lib.git refs/tags/*:refs/tags/* +refs/heads/*:refs/heads/* (launched in /Users/x/Library/Caches/org.carthage.CarthageKit/dependencies/lib)) failed with exit code 128:
remote: HTTP Basic: Access denied
remote: You must use a personal access token with 'api' scope for Git over HTTP.
remote: You can generate one at https://gitlab.corp.com/profile/personal_access_tokens
fatal: Authentication failed for 'https://gitlab.corp.com/path/to/lib.git/'

每个作业都有一个作业令牌,它应该使用它与 GitLab 进行通信。

如何临时将用户名gitlab-ci-token 和密码$CI_JOB_TOKEN 插入到 git credential-cache 存储中?

【问题讨论】:

    标签: git gitlab gitlab-ci carthage


    【解决方案1】:

    如何将用户名 gitlab-ci-token 和密码 $CI_JOB_TOKEN 临时插入 git credential-cache 存储区?

    这表明gitlab.corp.com URL 现在已经与 Windows 凭据管理器中的用户名/密码相关联(由 git 凭据帮助程序使用)。

    由于凭据管理器只能将一个凭据与一个 URL 关联,因此您可能需要切换到 SSH 方案,在该方案中您将没有令牌限制。
    这甚至可以通过以下命令自动完成:

    git config --global url.ssh://git@gitlab.corp.com/.insteadOf https://gitlab.corp.com/
    

    【讨论】:

    • 嗨@VonC https 是我唯一的选择,CI 运行器必须保持清洁。也在 macOS 上运行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-11
    • 1970-01-01
    • 2019-07-06
    • 2021-04-30
    • 1970-01-01
    • 1970-01-01
    • 2016-07-28
    相关资源
    最近更新 更多