完全解决 Jenkins Slaver 节点没法执行 Git-LFS 命令

最新配置新增一台iMac看成持续集成构建的Slaver节点,添加节点很顺利,可是拉取代码的时候发现没法正常。出现如下提示:java

hudson.plugins.git.GitException: Command "git checkout -f 1465f8d3b3afa59d3f40b876debd6e08988d3d39" returned status code 128:
stdout: 
stderr: git-lfs filter-process: git-lfs: command not found
fatal: The remote end hung up unexpectedly

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$900(CliGitAPIImpl.java:72)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2341)
复制代码

错误分析

错误中提示 git-lfs 找不到。git

  1. ssh远程登录主机查看大文件支持是否已经安装:app

    $ which git-lsf
     /usr/local/bin/git-lfs
    复制代码
  2. 若是不能看到以上结果,先安装大文件支持。ssh

    $ brew install git-lfs
     # 全局 git 的配置
     $ git lfs install
    复制代码

经过以上确定已经有了,重试了一次仍是没法正常拉取代码。说明命令行程序jenkins没法访问。咱们须要修正下默认环境。ui

解决方法

执行命令:spa

$ git --exec-path
/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
复制代码

得到了git的默认访问路径,将 git-lfs命令拷贝到该路径下。命令行

$ cp $(which git-lfs) /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
复制代码

若是提示无权限,在前头加上 sudo 就能成功。3d

Rebuild Jenkins集成任务搞定。code

相关文章
相关标签/搜索