GitLFS无法在Jenkins管道上运行

时间:2020-09-21 15:36:56

标签: jenkins-pipeline

使用Jenkinsfile通过SSH和HTTPS方法,SCM Checkout步骤不适用于GITLFS

def checkoutStep(branchname, repo, targetdir = "") {
    checkout changelog: false, poll: false,
    scm: [$class : 'GitSCM',
    branches : [[name: "${branchname}"]],
    browser : [$class: 'GithubWeb', repoUrl: "XXXXXXXX"],
    doGenerateSubmoduleConfigurations: false,
    extensions : [[$class: 'CleanCheckout'],
    [$class: 'CleanBeforeCheckout'],
    [$class: 'RelativeTargetDirectory', relativeTargetDir: "${targetdir}"],
    [$class: 'CloneOption', depth: 0, noTags: true, reference: '', shallow: false],
    [$class: 'GitLFSPull']],
    submoduleCfg : [],
    userRemoteConfigs : [[credentialsId: 'XXXXXXXXX', url: "git@github.com:XXXXXXX"]]]
}

将git https://github.com/XXXXXXX检出到/ var / jenkins_home / jobs / in-ci-pipeline-dev / workspace @ script中以读取Jenkinsfile 使用凭据XXXXXXXXXX

git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://github.com/XXXXXXX# timeout=10
Fetching upstream changes from https://github.com/XXXXXXX
git --version # timeout=10
using GIT_ASKPASS to set credentials XXXXXXXX credentials for the web
git fetch --tags --progress -- https://github.com/XXXXXXXX +refs/heads/:refs/remotes/origin/
git rev-parse dev/in-ci-jenkinsfile^{commit} # timeout=10
git rev-parse refs/remotes/origin/dev/in-ci-jenkinsfile^{commit} # timeout=10
Checking out Revision ffc2f625856285fe418ee344c46291fbb6c03b35 (refs/remotes/origin/dev/in- 
ci-jenkinsfile)
git config core.sparsecheckout # timeout=10
git checkout -f ffc2f625856285fe418ee344c46291fbb6c03b35
ERROR: Checkout failed
hudson.plugins.git.GitException: Command "git checkout -f 
ffc2f625856285fe418ee344c46291fbb6c03b35" returned status code 128:
stdout:
stderr: Downloading app-new/config/browscap.ini (88 MB)
Error downloading object: app-new/config/browscap.ini (ba81f69): Smudge error: Error downloading app-new/config/browscap.ini (ba81f6956fa350f2837ec9d3b61842719e8b984dbec3fd54140b66df0cf7e13d): batch response: Bad credentials

从stderr输出中:您可以在此处看到它已经在存储库中,并且当它试图使用gitlfs拉取88 MB的文件时,它将引发错误。

通过:HTTPS会引发错误的凭据错误 通过:SSH,它会引发未找到存储库错误。

最奇怪的是,这仅在我在管道中使用Jenkinsfile时发生,但是当我使用脚本方法时,它完全可以正常工作。

1 个答案:

答案 0 :(得分:0)

问题是jenkins作业配置本身未启用GitLFS选项。

当试图检出存在Jenkinsfile的分支时,它也在检出其他大文件。由于未在作业中启用GitLFS选项,因此无法检出。