jekins 从gitlab 拉取代码失败,文件名太长 Filename too long

队友一大早提交了代码,然后jekins自动部署就执行失败了。一脸懵逼的看了下控制台日志:

FATAL: Could not checkout 5790df9981485c35ae29d54d168de06c49961a7f
hudson.plugins.git.GitException: Command "D:\app\Git\Git\bin\git.exe checkout -f 5790df9981485c35ae29d54d168de06c49961a7f" returned status code 1:
stdout: 
stderr: error: unable to create file a.java: Filename too long
HEAD is now at 5790df99 Merge branch 'dev' into test

	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$1100(CliGitAPIImpl.java:86)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2999)
Caused: hudson.plugins.git.GitException: Could not checkout 5790df9981485c35ae29d54d168de06c49961a7f
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:3023)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1352)
	at hudson.scm.SCM.checkout(SCM.java:505)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1213)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
	at hudson.model.Run.execute(Run.java:1888)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
	at hudson.model.ResourceController.execute(ResourceController.java:99)
	at hudson.model.Executor.run(Executor.java:431)
SSH: Current build result is [FAILURE], not going to run.
Finished: FAILURE

关键信息其实就一行:


出于隐私,文件名我已经改成a了,原文件名还是挺长的。

那么怎么解决呢?总不能让人家改源码的文件名吧

其实很简单,就是一个git的配置而已

git config --global core.longpaths  true

但是这个全局的配置要怎么加呢?这个才是关键的地方。

本质就是在拉代码之前,执行的一个环境参数的命令

解决步骤如下:

  1. 安装插件jekins插件 Environment Injector

2.选择要执行的item,增加环境变量


3.配置变量设置脚本


4.保存,重新执行部署脚本,运行成功

举报
评论 0