Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 稀疏签出不会在工作目录中留下任何条目_Git_Jenkins_Jenkins Pipeline_Sparse Checkout - Fatal编程技术网

Git 稀疏签出不会在工作目录中留下任何条目

Git 稀疏签出不会在工作目录中留下任何条目,git,jenkins,jenkins-pipeline,sparse-checkout,Git,Jenkins,Jenkins Pipeline,Sparse Checkout,我试图使用稀疏签出选项来减少Jenkins管道中签出的大小。 它工作了一段时间,然后当我对脚本做了一些小修改(不在签出部分)时,我开始出现这个错误 pipeline { agent none parameters { string(name: 'CommitID', defaultValue: '', description: 'This is to take the commitID for checkout') choice choices: ['FRST

我试图使用稀疏签出选项来减少Jenkins管道中签出的大小。 它工作了一段时间,然后当我对脚本做了一些小修改(不在签出部分)时,我开始出现这个错误

pipeline {
  agent none
    parameters {
      string(name: 'CommitID', defaultValue: '', description: 'This is to take the commitID for checkout')
      choice choices: ['FRST', 'QA', 'PROD'], description: 'Please select the environment to which the package needs to be deployed', name: 'depServer'
  }
  options {
        buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5')
  }
  stages {
    stage('CodePull-Linux') {
      agent {
        node {
          label 'Master'
        }
      }
      steps {
        timestamps() {
            echo "Hello"
          // Checkout code from github incase commitID from the past is given
checkout([$class: 'GitSCM', branches: [[name: "${params.CommitID}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SparseCheckoutPaths', sparseCheckoutPaths: [[path: 'LINUX']]], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'fceddep', url: '<git_url>']]])        
          
        }
      }
    }
  }
}
然后我删除了稀疏签出扩展

詹金斯管道之后:

pipeline {
  agent none
    parameters {
      string(name: 'CommitID', defaultValue: '', description: 'This is to take the commitID for checkout')
      choice choices: ['FRST', 'QA', 'PROD'], description: 'Please select the environment to which the package needs to be deployed', name: 'depServer'
  }
  options {
        buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5')
  }
  stages {
    stage('CodePull-Linux') {
      agent {
        node {
          label 'Master'
        }
      }
      steps {
        timestamps() {
            echo "Hello"
          // Checkout code from github incase commitID from the past is given
checkout([$class: 'GitSCM', branches: [[name: "${params.CommitID}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'fceddep', url: 'git@github.ford.com:FC-MIS/DS_FCNA_GDW.git']]])
          
        }
      }
    }
  }
我仍然得到与稀疏签出相关的错误

Running on Jenkins in /var/jenkins_home/workspace/DEV/INFMD/DS_Deploy_test
[Pipeline] {
[Pipeline] timestamps
[Pipeline] {
[Pipeline] echo
11:00:35  Hello
[Pipeline] checkout
11:00:35  using credential fceddep
11:00:35   > git rev-parse --is-inside-work-tree # timeout=10
11:00:35  Fetching changes from the remote Git repository
11:00:35   > git config remote.origin.url git@github.ford.com:FC-MIS/DS_FCNA_GDW.git # timeout=10
11:00:35  Cleaning workspace
11:00:35   > git rev-parse --verify HEAD # timeout=10
11:00:35  Resetting working tree
11:00:35   > git reset --hard # timeout=10
11:00:35  ERROR: Error fetching remote repo 'origin'
11:00:35  hudson.plugins.git.GitException: Failed to fetch from git@github.ford.com:FC-MIS/DS_FCNA_GDW.git
11:00:35    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:909)
11:00:35    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1131)
11:00:35    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1167)
11:00:35    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
11:00:35    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
11:00:35    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
11:00:35    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
11:00:35    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
11:00:35    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
11:00:35    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
11:00:35    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
11:00:35    at java.lang.Thread.run(Thread.java:748)
11:00:35  Caused by: hudson.plugins.git.GitException: Command "git reset --hard" returned status code 128:
11:00:35  stdout: 
11:00:35  stderr: error: Sparse checkout leaves no entry on working directory
11:00:35  fatal: Could not reset index file to revision 'HEAD'.
11:00:35  
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2430)
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2360)
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2356)
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1916)
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.reset(CliGitAPIImpl.java:635)
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clean(CliGitAPIImpl.java:1006)
11:00:35    at hudson.plugins.git.extensions.impl.CleanBeforeCheckout.decorateFetchCommand(CleanBeforeCheckout.java:44)
11:00:35    at hudson.plugins.git.extensions.GitSCMExtension.decorateFetchCommand(GitSCMExtension.java:288)
11:00:35    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:905)
11:00:35    ... 11 more
[Pipeline] }
[Pipeline] // timestamps
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE

如果我遗漏了什么,请告诉我。谢谢大家!

我还没有找到这种行为的根本原因。但是,我能够通过删除作业并使用相同的脚本创建另一个作业来克服此错误。不确定是否有旧的运行和工作区中的新运行发生了冲突


谢谢大家!

我认为原因是
未能从git@github.ford.com:FC-MIS/DS_FCNA_GDW.git
。运行管道的
$USER
是什么?其ssh公钥是否已添加到github?我使用的是Jenkins凭据中配置的用户,该用户在使用SCM管道时能够提取文件,但显式签出失败,出现上述错误(在SCM管道和单独脚本中)。我正在尝试同时重置用户ID密码,看看是否有帮助。顺便问一下,哪个用户运行管道重要吗?无论用户运行管道,我都已将作业配置为仅使用一个ID进行签出。另外,为什么即使我删除了扩展名,错误也应该出现在稀疏签出上?
Running on Jenkins in /var/jenkins_home/workspace/DEV/INFMD/DS_Deploy_test
[Pipeline] {
[Pipeline] timestamps
[Pipeline] {
[Pipeline] echo
11:00:35  Hello
[Pipeline] checkout
11:00:35  using credential fceddep
11:00:35   > git rev-parse --is-inside-work-tree # timeout=10
11:00:35  Fetching changes from the remote Git repository
11:00:35   > git config remote.origin.url git@github.ford.com:FC-MIS/DS_FCNA_GDW.git # timeout=10
11:00:35  Cleaning workspace
11:00:35   > git rev-parse --verify HEAD # timeout=10
11:00:35  Resetting working tree
11:00:35   > git reset --hard # timeout=10
11:00:35  ERROR: Error fetching remote repo 'origin'
11:00:35  hudson.plugins.git.GitException: Failed to fetch from git@github.ford.com:FC-MIS/DS_FCNA_GDW.git
11:00:35    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:909)
11:00:35    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1131)
11:00:35    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1167)
11:00:35    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
11:00:35    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
11:00:35    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
11:00:35    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
11:00:35    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
11:00:35    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
11:00:35    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
11:00:35    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
11:00:35    at java.lang.Thread.run(Thread.java:748)
11:00:35  Caused by: hudson.plugins.git.GitException: Command "git reset --hard" returned status code 128:
11:00:35  stdout: 
11:00:35  stderr: error: Sparse checkout leaves no entry on working directory
11:00:35  fatal: Could not reset index file to revision 'HEAD'.
11:00:35  
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2430)
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2360)
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2356)
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1916)
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.reset(CliGitAPIImpl.java:635)
11:00:35    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clean(CliGitAPIImpl.java:1006)
11:00:35    at hudson.plugins.git.extensions.impl.CleanBeforeCheckout.decorateFetchCommand(CleanBeforeCheckout.java:44)
11:00:35    at hudson.plugins.git.extensions.GitSCMExtension.decorateFetchCommand(GitSCMExtension.java:288)
11:00:35    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:905)
11:00:35    ... 11 more
[Pipeline] }
[Pipeline] // timestamps
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE