【问题标题】:How to use git lfs in AWS CodeBuild?如何在 AWS CodeBuild 中使用 git lfs?
【发布时间】:2020-06-18 16:12:01
【问题描述】:

由于 AWS CodeBuild 似乎不支持 git LFS(大型文件系统),我尝试安装它:

version: 0.2

phases:
  install:
    commands:
      - apt-get install -y bash curl
      - curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
      - apt-get install -y git-lfs
  pre_build:
    commands:
      - echo Downloading LFS files
      - git lfs pull
  build:
    commands:
      - echo Build started on `date`
  post_build:
    commands:
      - echo Build completed on `date`

对于上述代码,我收到以下错误(重命名的 repo 地址):

[Container] 2020/06/18 16:02:17 Running command git lfs pull
fatal: could not read Password for 'https://username@bitbucket.org': No such device or address
batch response: Git credentials for https://username@bitbucket.org/company/repo.git not found.
error: failed to fetch some objects from 'https://username@bitbucket.org/company/repo.git/info/lfs'

[Container] 2020/06/18 16:02:17 Command did not exit successfully git lfs pull exit status 2
[Container] 2020/06/18 16:02:17 Phase complete: PRE_BUILD State: FAILED
[Container] 2020/06/18 16:02:17 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: git lfs pull. Reason: exit status 2

我可以做其他事情来获取 LFS 文件吗?

【问题讨论】:

    标签: amazon-web-services aws-codebuild


    【解决方案1】:

    CodeBuild 本身不支持 git LFS。解决方法是设置 Git LFS 1 并克隆存储库 2 作为 buildspec.yml 执行的一部分。

    在 CodeBuild 的 buildspec 中使用 'git-credential-helper: yes' 为 git 命令 3 提供凭据。

    【讨论】:

    • 我尝试添加 'git-credential-helper: yes' 以保留 AWS CodeBuild 上下文(即,无需再次克隆),但没有成功。知道为什么将 git 凭据添加到我上面的 buildspec.yml 失败了吗?
    • 请查看此回复以获取建议:stackoverflow.com/questions/48652545/…
    【解决方案2】:

    CodeBuild 不支持 Git LFS,但可以即时安装它,然后从源目录运行 git lfs pull 以下载文件。像这样:

    env:
      git-credential-helper: yes
    
    phases:
      install:
        commands:
          - cd /tmp/
          - curl -OJL https://github.com/git-lfs/git-lfs/releases/download/v2.13.2/git-lfs-linux-amd64-v2.13.2.tar.gz
          - tar xzf git-lfs-linux-amd64-v2.13.2.tar.gz
          - ./install.sh
          - cd $CODEBUILD_SRC_DIR
    
      pre_build:
        commands:
          - git lfs pull
    
    <rest of your buildspec.yml file>
    

    【讨论】:

    • 这对我不起作用。我收到错误 Not in a git repository.
    猜你喜欢
    • 2022-12-28
    • 2021-04-15
    • 2020-11-29
    • 2018-07-17
    • 1970-01-01
    • 1970-01-01
    • 2022-06-14
    • 1970-01-01
    • 2020-10-13
    相关资源
    最近更新 更多