从 Jenkins 构建时出现 GIT LFS (git-lfs) 错误

问题描述 投票:0回答:1

使用 Jenkins 时无法成功从 GIT 中检出大型代码文件。我已经在我的代理机器上验证了我可以提取整个 GIT 存储库并进行构建。我之前在代理机器上安装了 GIT-LFS。因此,它绝对仅限于使用 Jenkins 进行构建。 我还验证了我可以拥有一个从 git 提取代码的管道,并且只要不使用 git-lfs 就可以成功构建。 我在控制台窗口中遇到的错误是:

stderr: git-lfs filter-process: line 1: git-lfs: command not found

我找到了这篇 StackOverflow 文章并尝试了其中的想法,但没有成功: jenkins 中的 Git LFS 设置

我无法再找到参考资料,但我确实看到提到 Jenkins 代理可能正在某个特定位置寻找 git-lfs 而没有找到它。这也许可以解释为什么我可以从代理计算机上的命令窗口执行 git clone、git pull 等操作而没有任何问题?

下面我粘贴了我正在使用的管道脚本。正如您从注释掉的代码中看到的,我尝试了各种组合。为了充分披露,我相信 git-lfs 插件已安装,但我没有管理员权限说 100%。我本以为如果不安装的话会得到不同的错误,但是有没有办法验证?我还看到提到应该可以在不使用插件的情况下完成所有这些工作。

有什么想法吗?谢谢!

pipeline {
agent { label 'WindowsFoo' }//any
tools {
    msbuild 'MSBuild 2022' // I don't believe this is used!
}

stages {
    stage ('Clean workspace') {
          steps {
            // Clean before build
            cleanWs()  // 
            // cleanWs fails if ANY console window is open or windows explorer open to the repository  
             
          }
        }
        
    stage('Checkout') {
        steps {

                 echo 'checkout'
                
                
                    script 
                    {
                    
                        git credentialsId: 'Foo_ID', url: 'https://github.com/Foo/Foo-software.git'
                        
                       
                         
                         checkout([
                $class: 'GitSCM',
                branches: [[name: '*/master']],
                doGenerateSubmoduleConfigurations: false,
                extensions: [[$class: 'GitLFSPull']],   //extensions: [lfs()],
                submoduleCfg: [],
                userRemoteConfigs: [[url: 'https://github.com/Foo/Foo-software.git']]
                      ])  
                      
                    }                   
        }
    }

}

}

FWIW,代理机器是 Windows 10 机器。

git jenkins-pipeline jenkins-plugins git-lfs
1个回答
0
投票

我需要做几件事才能让 git-lfs 工作。在这里,我为其他可能遇到困难的人发布了更新的脚本文件。我是 Jenkins 和 msbuild 的新手,至少可以说我确实觉得它们很烦人!有不少“陷阱”。举个例子。看起来您的 GIT 存储库需要一个“主”分支。如果没有,詹金斯就会报错。另一方面,如果命令窗口和/或 Windows 资源管理器打开工作区,cleanWs 将无法工作。我认为这是有道理的,但错误消息非常神秘。这是我的新脚本文件:

     pipeline {
    agent { label 'WindowsFoo' }
    tools {
        msbuild 'MSBuild 2022'  // I don't think this is used
    }

    stages {
        stage ('Clean workspace') {
              steps {
                // Clean before build
                cleanWs()  
                // IT fails if ANY console window is open or windows explorer
                
              }
            }
            
        stage('Checkout') {
            steps {
 //               checkout scm
                     echo 'checkout beginning of method'
                    
                    
                        script 
                        {
                            // doing this credentialsId seems to create a pull?
                            //git credentialsId: 'FooGIT_ID', url: 'https://github.com/Foo/Foo-software.git'
                            echo 'just called git credentials'
                           
                            
                             echo 'call checkout'
                              checkout scmGit(branches: [[name: '*/master']], extensions: [lfs(), checkoutOption(120)], userRemoteConfigs: [[credentialsId: 'FooGIT_ID', url: 'https://github.com/Foo/Foo-software.git']])    
                             
                  }
                    
                    
            }
        }
      
}

           
           
           
        
© www.soinside.com 2019 - 2024. All rights reserved.