如何在 GitLab Windows Runner 上使用外部 Git LFS 服务器?

3
我正在尝试在由我控制的Windows GitLab Runner上使用外部git-lfs服务器。所使用的git-lfs服务器仅提供HTTPS身份验证(SSH不可用)。出于安全原因,我不想将我的凭据提交到文件.lfsconfig中。 针对Linux,我找到了这个答案并为我的目的进行了调整:
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作业?
1个回答

1
我使用以下语法在Windows GitLab Runner的配置文件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'
  """

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接