jenkins Caused by: java.io.IOException: Cannot run program “git.exe“

背景

在Jenkins上去拉代理机器上的代码,但是报错,报错信息如下:

hudson.plugins.git.GitException: Error performing git command: git.exe rev-parse --is-inside-work-tree
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2437)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2360)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2356)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1916)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1928)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.hasGitRepo(CliGitAPIImpl.java:343)
	at hudson.plugins.git.GitAPI.hasGitRepo(GitAPI.java:232)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:931)
	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:905)
	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:857)
	at hudson.remoting.UserRequest.perform(UserRequest.java:211)
	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
	at hudson.remoting.Request$2.run(Request.java:369)
	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:117)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Cannot run program "git.exe" (in directory "E:\test\cdm"): CreateProcess error=2, The system cannot find the file specified
	at java.lang.ProcessBuilder.start(Unknown Source)
	at hudson.Proc$LocalProc.<init>(Proc.java:252)
	at hudson.Proc$LocalProc.<init>(Proc.java:221)
	at hudson.Launcher$LocalLauncher.launch(Launcher.java:936)
	at hudson.Launcher$ProcStarter.start(Launcher.java:454)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2423)
	... 22 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
	at java.lang.ProcessImpl.create(Native Method)
	at java.lang.ProcessImpl.<init>(Unknown Source)
	at java.lang.ProcessImpl.start(Unknown Source)
	... 28 more

解决方法

在Jenkins -- Nodes -- 选择要操作的机器 -- Configure -- Tool Locations

添加git在机器上的git.exe的路径

### 解决Jenkins编译过程中的`hudson.remoting.ProxyException: java.lang.reflect.InvocationTargetException`错误 当遇到`hudson.remoting.ProxyException: java.lang.reflect.InvocationTargetException`这类异常时,通常意味着远程调用过程中发生了未预期的情况。此类问题可能由多种因素引起,包括但不限于环境配置不当、依赖库版本冲突或是特定工具链之间的兼容性问题。 #### 检查Jenkins及其插件版本 确保使用的Jenkins版本是最新的稳定版之一。旧版本可能存在已知缺陷或与当前软件生态系统的兼容性问题。对于提及的具体情况,建议升级至更高版本的Jenkins以获得更好的支持和稳定性[^1]。 #### 更新Maven版本 如果项目构建涉及Maven,则应确认所使用的Maven版本是否适合该项目的要求。有时降低或提升Maven版本可以绕过一些潜在的问题。例如,从较高版本回退到较低版本可能会解决问题,正如之前的经验所示,调整Maven版本确实帮助解决了某些情况下出现的问题[^2]。 #### 审视代码变更历史记录 仔细审查最近提交的历史记录,特别是那些引入新功能或重构现有逻辑的部分。任何破坏性的更改都可能是触发此异常的原因所在。重点检查是否有对类加载器进行了操作或者是反射机制的应用场景。 #### 调整Java虚拟机参数 适当调节启动Jenkins服务时传递给Java虚拟机(JVM)的相关选项也可能有助于缓解该问题。比如增加堆内存大小(-Xmx),启用更多的垃圾回收日志输出等措施可以帮助诊断根本原因。 #### 启用详细的调试信息 为了更深入地了解发生的位置以及上下文条件,在Jenkins的日志级别设置中开启DEBUG模式能够提供额外的信息用于分析。这一步骤往往能揭示更多关于失败背后的故事线索。 ```bash java -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog \ -Dorg.apache.commons.logging.simplelog.showdatetime=true \ -Dorg.apache.commons.logging.simplelog.log.org.jenkinsci.plugins.git.traits=debug \ -jar jenkins.war ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值