GitLFSPull SCM Jenkins插件无法进行正确的git-lfs pull来解析指针



背景:我正在将Git LFS与repo一起使用,我们需要在为Pipeline使用Jenkins的groovy函数的同时,在签出逻辑中执行Git LFS。这样做的目的是用稍后在CI计算阶段使用的实际文件替换指针。

问题:GitLFSPull SCM插件存在,用作scmExtension时工作正常,但它没有给出预期的结果,基本上插件激活了,状态如下,但我怀疑git lfs pull origin不工作

Enabling Git LFS pull
> git rev-parse refs/remotes/origin/feature/xyz^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/feature/xyz^{commit} # timeout=10
> git config core.sparsecheckout # timeout=10
> git checkout -f hash # timeout=10
> git config --get remote.origin.url # timeout=10
> git lfs pull origin # timeout=10

我想知道,我是否错过了正确使用Jenkins插件的东西?下面是我们使用的Checkout功能

def checkoutSourceCode(checkoutDir) {
dir(checkoutDir) {
checkout changelog: true,
poll: true,
scm: [$class: 'GitSCM',
branches: [[name: "origin/" + params.SOURCE_BRANCH]],
doGenerateSubmoduleConfigurations: false,
extensions                       : [
[$class: 'CloneOption', noTags: true, reference: '', shallow: false],
[$class: 'CleanBeforeCheckout'],
[$class: 'PruneStaleBranch'],
[$class: 'AuthorInChangelog'],
[$class: 'GitLFSPull']
[$class: 'UserIdentity', email: 'xyz@gmail.com', name: 'xyzzy'],
[$class: 'SubmoduleOption',
disableSubmodules  : false,
parentCredentials  : true,
recursiveSubmodules: true,
reference          : '',
trackingSubmodules : false]],
submoduleCfg                     : [],
userRemoteConfigs                : [[name         : 'origin',
credentialsId: 'xyzzy',
url          : 'ssh://xyz.xyn.com/something.git']]]
gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
shortCommit = gitCommit.take(6)
return shortCommit
}
}

所以这就是解决这个问题的方法。为了我和追踪。

  • brew install git-lfs
  • 我不得不将LFS($whereis git-lfs)的Symlink与系统usrbin<>的Symlink添加在一起,这样CI运行的master系统就知道LFS在哪里,而主系统却找不到LFS在那里
  • 最后,在groovy脚本中使用sh检查git lfs status作为CLI命令以确保LFS存在

我看到一个问题,看起来你已经解决了这个问题。但我在你的詹金斯文件中看到了一个小问题,看起来你少了一个逗号。

[$class: 'GitLFSPull'], <-- here
[$class: 'UserIdentity', email: 'xyz@gmail.com', name: 'xyzzy'],

最新更新