• jenkins 拉取git仓库报错: stderr: fatal: not in a git directory


    jenkins 报错日志

    ERROR: Error fetching remote repo 'origin'
    hudson.plugins.git.GitException: Failed to fetch from https://gitee.com/xxx/xxx.git
    	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999)
    	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1241)
    	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305)
    	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
    	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
    	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
    	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.base/java.lang.Thread.run(Unknown Source)
    Caused by: hudson.plugins.git.GitException: Command "git config remote.origin.url https://gitee.com/xxx/xxx.git" returned status code 128:
    stdout: 
    stderr: fatal: not in a git directory
    
    	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2846)
    	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2766)
    	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2761)
    	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2051)
    	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2063)
    	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.setRemoteUrl(CliGitAPIImpl.java:1662)
    	at hudson.plugins.git.GitAPI.setRemoteUrl(GitAPI.java:180)
    	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:987)
    	... 11 more
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    解决方法

    执行以下命令(如果是容器化部署,直接进入容器执行)

    git config --global --add safe.directory '*'
    
    • 1
  • 相关阅读:
    Git目录不对,即当前文件夹不对应git仓库
    ChiQA
    【图像处理】基于matlab GUI图像处理【含Matlab源码 2123期】
    基于SSM的智慧城市实验室主页系统的设计与实现
    HashData的湖仓一体思考:Iceberg、Hudi特性讲解与支持方案
    Java设计模式 _行为型模式_备忘录模式
    2.2 Go语言中的布尔型和整型
    【数据库】期末复习(计科版)
    【BOM】location对象
    python 包之 selenium 自动化使用教程
  • 原文地址:https://blog.csdn.net/qq_36940806/article/details/136719683