[Jenkins][git]构建时提示Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git reset --hard" returned status code 128:

摘要:
---------------------如果您需要重新打印,请注明来源---------------------今天,我发现所有与IOS构建相关的作业都失败了,并提示以下错误:错误:Errorfetchingremoterepo'origin'hudson.plugins.git。GitException:调用失败hfromhttp://git.xxxx/ios/xxxx-ios.

---------------------

如需转载,转载请注明出处。

---------------------

今日发现所有IOS构建相关的job全部失败,并提示如下错误:

ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from http://git.xxxx/ios/xxxx-ios.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:810)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1066)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1097)
    at hudson.scm.SCM.checkout(SCM.java:485)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
    at hudson.model.Run.execute(Run.java:1741)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git reset --hard" returned status code 128:
stdout: 
stderr: error: bad signature
fatal: index file corrupt
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1719)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1695)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1691)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1321)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.reset(CliGitAPIImpl.java:372)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clean(CliGitAPIImpl.java:670)
    at hudson.plugins.git.GitAPI.clean(GitAPI.java:311)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:884)
    at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:859)
    at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:818)
    at hudson.remoting.UserRequest.perform(UserRequest.java:152)
    at hudson.remoting.UserRequest.perform(UserRequest.java:50)
    at hudson.remoting.Request$2.run(Request.java:332)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at hudson.remoting.Engine$1$1.run(Engine.java:85)
    at java.lang.Thread.run(Thread.java:745)
    at ......remote call to qa-ios4-macpro(Native Method)
    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:252)
    at hudson.remoting.Channel.call(Channel.java:781)
    at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:249)
    at com.sun.proxy.$Proxy76.clean(Unknown Source)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl.clean(RemoteGitImpl.java:453)
    at hudson.plugins.git.extensions.impl.CleanBeforeCheckout.decorateFetchCommand(CleanBeforeCheckout.java:32)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:806)
    ... 11more
ERROR: null

解决思路:

其实遇到这种问题的原因有很多,大致如下:

1. Linux/Mac的权限问题:确保启动Jenkins服务的用户自身有Jenkins所在目录的权限。(比如用非root用户权限进行操作)

2. 账号权限问题:确保Job里选择的Credentials账号有权限,GIT对应的SSH配置存在。

3. 工程目录损坏问题:在workspace工程目录下,尝试git命令是否可用。

[Jenkins][git]构建时提示Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git reset --hard" returned status code 128:第1张

发现提示:

error: bad signature
fatal: index file corrupt

说明:

index file在git中指的是.git/index这个文件。这个文件保存的是暂存区的信息,也就是索引信息。

可以通过 git ls-files --stage 来查看暂存区的内容。

通过错误信息fatal:index file corrupt,可以看出这个文件已经损坏。 可以通过git reset来恢复。

解决方法:

1. 进入工程目录下:/Users/Shared/Jenkins/Home/jenkins/workspace/xxxx-ios/.git

2. 删除或重命名.git目录下的index文件:rm -f .git/index或mv .git/index.bak

3. 重新生成index文件:git reset

4. 检查是否可用:git status

[Jenkins][git]构建时提示Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git reset --hard" returned status code 128:第2张

再次构建,成功,cheers~

今日发现,提交代码后,Jenkins没有自动构建,进入相应工程目录后发现:

[Jenkins][git]构建时提示Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git reset --hard" returned status code 128:第3张

提示如下:

fatal: index file smaller than expected

使用本文所写的方法即可解决。

[Jenkins][git]构建时提示Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git reset --hard" returned status code 128:第4张

免责声明:文章转载自《[Jenkins][git]构建时提示Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git reset --hard" returned status code 128:》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇浅析射线检测 raycast 的使用 !Cocos Creator 3D !Python微信库:itchat下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

springBoot 项目 Jenkins+svn 集成部署

持续集成工具Jenkins 持续部署、持续集成、持续交付 Jenkins 和 Hudson 都是一款持续集成及自动化部署工具。 Jenkins 解决了什么问题: Jenkins 的主要目标是监控软件开发流程,快速显示问题。所以能保证开发人员以及相 关人员省时省力提高开发效率。 解决了传统的打包、部署枯燥过程。 Jenkins 主要用于 1.持续、自动地构建...

android结合Jenkins使用V2签名

今日客户对安卓apk进行代码扫描时发现漏洞,后经过研究解决办法为安卓V2签名。 解决办法:Jenkins只能用命令行去设置签名。 步骤1:ZipAlign zip对齐,因为APK包的本质是一个zip压缩文档,经过边界对齐方式优化能使包内未压缩的数据有序的排列,从而减少应用程序运行时的内存消耗 ,通过空间换时间的方式提高执行效率(zipalign后的apk...

Jenkins 配置git

点击"新建任务"创建一个自用风格的项目 点击"源码管理",选择 git  系统管理 --> Global Tool Configuration<为访问git服务添加认证-----------------上图 Credential 中的 add> 配置deploy-key 如下配置,jenkins服务器上root用户生成密钥对...

[Jenkins]初次访问Jenkins,输入密码后,页面卡在空白界面一直未加载出内容_解决方案

问题描述 安装Jenkins,初次访问Jenkins(http://localhost:8002,端口号根据各自设置而不同,本例是8002),输入Jenkins初始化的管理密码之后,浏览器中一直卡在空白界面中,没有内容加载出来 异常界面 问题分析 F12查看浏览器中的Request和Response情况: 从Request URL中初步分析...

jenkins-2-3分钟学会汉化

前言 唉呀!记得刚接触 jenkins 的时候,是开发交给我们用的怎样构建,一开打jenkins~怎么都是英文的(小龙英文不好....) 不过我们可以汉化,一点也不影响使用,随时也能切换中英文及繁体。 一、插件安装 1、Manage Jenkins --> Manage Plugins --> Available 先下载好此插件,搜索:Loca...

jenkins下JDK、Maven、Gradle、SVN、Tomcat、SDK安装配置

1.JDK安装与配置: 1)下载jdk,根据安装步骤一直点击下一步进行安装,安装完后配置环境变量 计算机→属性→高级系统设置→高级→环境变量 2)系统变量→新建 JAVA_HOME 变量 ,变量值填写jdk的安装目录 3)系统变量→寻找 Path 变量→编辑, 在变量值最后输入%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin; (...