Gitlab:通过部署密钥访问 git lfs 文件

Gitlab: Access git lfs files through deploy keys

我正在使用 Gitlab Community Edition 8.13.7,想将我们的项目切换为使用 git lfs。

我使用 git-lfs 设置了一个测试项目,它可以很好地使用 git-lfs 进行克隆、推送和拉取。在我们的 jenkins-ci 上使用相同的项目后,克隆失败。

在 jenkins 机器上安装 git-lfs 之前,我可以很好地克隆项目,并且会看到二进制文件被替换为指针文件。

cat image.iso
version https://git-lfs.github.com/spec/v1
oid sha256:1e1c4ea8348914d81385e4801de6ba34baa6ed6c4eb4f4cd026d0659eaa459de
size 111691252

安装 git-lfs 后出现以下错误:

stderr: Downloading image.iso (112 MB)
Error downloading object: image.iso (1e1c4ea): Smudge error: 
Error downloading image.iso (1e1c4ea8348914d81385e4801de6ba34baa6ed6c4eb4f4cd026d0659eaa459de): batch response:
Fatal error: Server error: http://gitlab-01.carsten.net/carsten/testing-lfs.git/info/lfs/objects/batch
Errors logged to /data/jenkins/tkn-01/lygteskov-test-lfs/.git/lfs/objects/logs/20170711T155641.879051717.log
Use `git lfs logs last` to view the log.
error: external filter git-lfs smudge -- %f failed 2
error: external filter git-lfs smudge -- %f failed
fatal: image.iso: smudge filter lfs failed` 

最后来自 git lfs 日志的输出:

git-lfs/2.2.1 (GitHub; linux amd64; go 1.8.3; git 621d1f82)
git version 2.0.5

$ git-lfs smudge -- image.iso
Error downloading object: image.iso (1e1c4ea): Smudge error: Error downloading image.iso (1e1c4ea8348914d81385e4801de6ba34baa6ed6c4eb4f4cd026d0659eaa459de): batch response: Fatal error: Server error: http://gitlab-01.carsten.net/carsten/testing-lfs.git/info/lfs/objects/batch

Server error: http://gitlab-01.carsten.net/carsten/testing-lfs.git/info/lfs/objects/batch
github.com/git-lfs/git-lfs/errors.Errorf
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/errors/errors.go:69
github.com/git-lfs/git-lfs/lfsapi.defaultError
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/lfsapi/errors.go:114
github.com/git-lfs/git-lfs/lfsapi.(*Client).handleResponse
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/lfsapi/errors.go:51
github.com/git-lfs/git-lfs/lfsapi.(*Client).Do
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/lfsapi/client.go:80
github.com/git-lfs/git-lfs/lfsapi.(*Client).doWithCreds
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/lfsapi/auth.go:74
github.com/git-lfs/git-lfs/lfsapi.(*Client).DoWithAuth
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/lfsapi/auth.go:44
github.com/git-lfs/git-lfs/tq.(*tqClient).Batch
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/tq/api.go:60
github.com/git-lfs/git-lfs/tq.Batch
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/tq/api.go:36
github.com/git-lfs/git-lfs/tq.(*TransferQueue).enqueueAndCollectRetriesFor
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/tq/transfer_queue.go:286
github.com/git-lfs/git-lfs/tq.(*TransferQueue).collectBatches
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/tq/transfer_queue.go:258
runtime.goexit
        /usr/local/Cellar/go/1.8.3/libexec/src/runtime/asm_amd64.s:2197
github.com/git-lfs/git-lfs/errors.newWrappedError
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/errors/types.go:170: Fatal error
github.com/git-lfs/git-lfs/errors.newWrappedError
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/errors/types.go:170: batch response
github.com/git-lfs/git-lfs/errors.newWrappedError
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/errors/types.go:170: Error downloading image.iso (1e1c4ea8348914d81385e4801de6ba34baa6ed6c4eb4f4cd026d0659eaa459de)
github.com/git-lfs/git-lfs/errors.newWrappedError
        /Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/errors/types.go:170: Smudge error

ENV:
LocalWorkingDir=/data/jenkins/tkn-01/lygteskov-test-lfs
LocalGitDir=/data/jenkins/tkn-01/lygteskov-test-lfs/.git
LocalGitStorageDir=/data/jenkins/tkn-01/lygteskov-test-lfs/.git
LocalMediaDir=/data/jenkins/tkn-01/lygteskov-test-lfs/.git/lfs/objects
LocalReferenceDir=
TempDir=/data/jenkins/tkn-01/lygteskov-test-lfs/.git/lfs/tmp
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic
UploadTransfers=basic
GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
GIT_DIR=.git
GIT_REFLOG_ACTION=pull origin master
GIT_PREFIX=

通过将克隆的 git url 从 ssh 切换到 http:

解决了这个问题