Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-66149

Git plugin reports error on first build when checking out to subdirectory

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • git-plugin
    • None
    • Git plugin 4.7.1

      When running the *first build* for a Jenkinsfile like

      node {
      	checkout(changelog: false, scm: [$class: 'GitSCM', branches: [[name: '*/master']], 
      		extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'foo']], 
      		userRemoteConfigs: [[url: 'https://github.com/jenkinsci/git-plugin.git']]])
      }
      

      we get the following error message in the console log:

      2:52:09  The recommended git tool is: NONE
      12:52:09  No credentials specified
      12:52:09  Cloning the remote Git repository
      12:52:09  Cloning repository https://github.com/jenkinsci/git-plugin.git
      12:52:09   > git init D:\slave\workspace\dbox_feature_test-first-build_17\foo # timeout=60
      12:52:10  Fetching upstream changes from https://github.com/jenkinsci/git-plugin.git
      12:52:10   > git --version # timeout=60
      12:52:10   > git --version # 'git version 2.24.1.windows.2'
      12:52:10   > git fetch --tags --force --progress -- https://github.com/jenkinsci/git-plugin.git +refs/heads/*:refs/remotes/origin/* # timeout=60
      12:52:12   > git config remote.origin.url https://github.com/jenkinsci/git-plugin.git # timeout=60
      12:52:12  Avoid second fetch
      12:52:12  Checking out Revision 499cd33301cfa63ddb48a03a8bc2cce0cc4beb8a (refs/remotes/origin/master)
      12:52:12   > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=60
      12:52:12   > git rev-parse "refs/remotes/origin/master^{commit}" # timeout=60
      12:52:12   > git config core.sparsecheckout # timeout=60
      12:52:12   > git checkout -f 499cd33301cfa63ddb48a03a8bc2cce0cc4beb8a # timeout=60
      12:52:13  Commit message: "Merge pull request #1107 from MarkEWaite/revert-spotbugs-code-change"
      12:52:13   > git --version # timeout=60
      12:52:13   > git --version # 'git version 2.24.1.windows.2'
      12:52:14  fatal: not a git repository (or any of the parent directories): .git
      

      Works fine when triggering the 2nd, 3rd, ... builds - or when not using the relativeTargetDir option.

            markewaite Mark Waite
            macdrega Joerg Schwaerzler
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: