【问题标题】:Using external git-lfs server in gitlab-ci on a windows gitlab runner?在 Windows gitlab 运行器上的 gitlab-ci 中使用外部 git-lfs 服务器?
【发布时间】:2020-12-14 21:05:30
【问题描述】:

我正在尝试使用外部 git-lfs 服务器来执行在 windows gitlab 运行器(在我的控制之下)上运行的作业。使用的 git-lfs 服务器仅提供 HTTPS 身份验证(SSH 不是一个选项)。出于安全原因,我不想将我的凭据提交到 .lfsconfig 文件中。

对于 Linux,我找到了这个 answer 并根据我的目的对其进行了调整:

git config --global credential.mydomain.helper '!f() { echo "username=${GIT_LFS_USER}"; echo "password=${GIT_LFS_PASSWORD}"; }; f'

我尝试在使用的 Windows gitlab-runner 上配置它(config.toml 中的 pre_clone_script 选项),但是我没有设法让它工作(我从 lfs 服务器获得授权被拒绝)而且我没有确保这可以工作,因为据我了解,Windows git 默认使用 Windows 凭据管理器。

如何提供外部 git-lfs 服务器的凭据以在 Windows gitlab-runner 上运行 gitlab-ci 作业?

【问题讨论】:

    标签: windows git gitlab-ci git-lfs


    【解决方案1】:

    我设法在 windows gitlab 运行器的配置文件 config.toml 中使用此语法使其工作(将 myusernamemyurlmypassword 替换为真实字符串):

    pre_clone_script="""git config --global credential.https://myurl.com.username "myusername"
    git config --global "credential.https://myurl.com.helper" '!f() { echo password="mypassword"; }; f'
      """
    

    为了更简洁,可以在每个 gitlab 的项目配置中使用pre_clone_script="Invoke-Command $CI_PRE_CLONE_SCRIPT" 并定义CI_PRE_CLONE_SCRIPT

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-08
      • 1970-01-01
      • 2021-06-20
      • 1970-01-01
      • 1970-01-01
      • 2017-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多