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

Git plugin checking out non-existent submodule from different branch

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-plugin
    • None
    • Jenkins 2.13, Git Plugin 2.5.3

      I'm seeing an issue when doing a recursive checkout of submodules in our repository where the Git plugin will attempt to check out a non-existent submodule that was recently added in a different branch but has not yet been merged. This is causing all subsequent builds to fail that have not yet had a merge to include this submodule. Here is an excerpt from our build logs:

      I've blanked out sensitive path information with ***, just an FYI:
      11:19:09 Checking out Revision *** (origin/master)
      11:19:09 > git config core.sparsecheckout # timeout=10
      11:19:09 > git checkout -f ***
      11:19:10 > git rev-list *** # timeout=10

      11:19:10 > git remote # timeout=10
      11:19:10 > git submodule init # timeout=10

      11:19:12 > git submodule sync # timeout=10

      11:19:18 > git config --get remote.origin.url # timeout=10

      11:19:18 > git config --get-regexp ^submodule # timeout=10
      11:19:19 > git config --get submodule.BuildFiles/***.url # timeout=10
      11:19:19 > git submodule update --init --recursive BuildFiles/***

      11:19:23 > git config --get submodule.***.url # timeout=10
      11:19:23 > git submodule update --init --recursive ***

      11:19:27 > git config --get submodule.test/***.url # timeout=10

      11:19:27 > git submodule update --init --recursive test/***

      11:19:29 FATAL: Command "git submodule update --init --recursive test/***" returned status code 1:
      11:19:29 stdout:
      11:19:29 stderr: error: pathspec 'test/***' did not match any file(s) known to git.
      11:19:29
      11:19:29 hudson.plugins.git.GitException: Command "git submodule update --init --recursive test/**" returned status code 1:
      11:19:29 stdout:
      11:19:29 stderr: error: pathspec 'test/***' did not match any file(s) known to git.

      I've traced the issue to the command "git config --get-regexp ^submodule". This is picking up the offending submodule and including it in the recursive update, despite it not being attached to the commit in question. This seems to be a problem with the Git program itself but when I do a recursive update from the command line, I don't see this issue. It seems to be attached to the process through which the Jenkins Git plugin identifies the submodules present. Would it be possible to add a check so the update does not include submodules that don't exist in the commit being targeted? I assume this will be resolved once the submodule gets merged into master but it's very inconvenient for the time being as all our follow-up builds are now failing.

      I'm not sure if this is relevant but the current branch setup has it pointed to a detached head on a specific commit. This could be impacting how the submodules are being picked up and returned.

      Thanks!

          [JENKINS-37419] Git plugin checking out non-existent submodule from different branch

          Nick Lykins created issue -
          Nick Lykins made changes -
          Description Original: I'm seeing an issue when doing a recursive checkout of submodules in our repository where the Git plugin will attempt to check out a non-existent submodule that was recently added in a different branch but has not yet been merged. This is causing all subsequent builds to fail that have not yet had a merge to include this submodule. Here is an excerpt from our build logs:

          I've blanked out sensitive path information with ***, just an FYI:
          11:19:09 Checking out Revision *** (origin/master)
          11:19:09 > git config core.sparsecheckout # timeout=10
          11:19:09 > git checkout -f ***
          11:19:10 > git rev-list *** # timeout=10

          11:19:10 > git remote # timeout=10
          11:19:10 > git submodule init # timeout=10

          11:19:12 > git submodule sync # timeout=10

          11:19:18 > git config --get remote.origin.url # timeout=10

          11:19:18 > git config --get-regexp ^submodule # timeout=10
          11:19:19 > git config --get submodule.BuildFiles/***.url # timeout=10
          11:19:19 > git submodule update --init --recursive BuildFiles/***

          11:19:23 > git config --get submodule.***.url # timeout=10
          11:19:23 > git submodule update --init --recursive ***

          11:19:27 > git config --get submodule.test/***.url # timeout=10

          11:19:27 > git submodule update --init --recursive test/***

          11:19:29 FATAL: Command "git submodule update --init --recursive test/***" returned status code 1:
          11:19:29 stdout:
          11:19:29 stderr: error: pathspec 'test/***' did not match any file(s) known to git.
          11:19:29
          11:19:29 hudson.plugins.git.GitException: Command "git submodule update --init --recursive test/**" returned status code 1:
          11:19:29 stdout:
          11:19:29 stderr: error: pathspec 'test/***' did not match any file(s) known to git.

          I've traced the issue to the command "git config --get-regexp ^submodule". This is picking up the offending submodule and including it in the recursive update, despite it not being attached to the commit in question. This seems to be a problem with the Git program itself but when I do a recursive update from the command line, I don't see this issue. It seems to be attached to the process through which the Jenkins Git plugin identifies the submodules present. Would it be possible to add a check so the update does not include submodules that don't exist in the commit being targeted? I assume this will be resolved once the submodule gets merged into master but it's very inconvenient for the time being as all our follow-up builds are now failing.

          Thanks!
          New: I'm seeing an issue when doing a recursive checkout of submodules in our repository where the Git plugin will attempt to check out a non-existent submodule that was recently added in a different branch but has not yet been merged. This is causing all subsequent builds to fail that have not yet had a merge to include this submodule. Here is an excerpt from our build logs:

          I've blanked out sensitive path information with ***, just an FYI:
          11:19:09 Checking out Revision *** (origin/master)
          11:19:09 > git config core.sparsecheckout # timeout=10
          11:19:09 > git checkout -f ***
          11:19:10 > git rev-list *** # timeout=10

          11:19:10 > git remote # timeout=10
          11:19:10 > git submodule init # timeout=10

          11:19:12 > git submodule sync # timeout=10

          11:19:18 > git config --get remote.origin.url # timeout=10

          11:19:18 > git config --get-regexp ^submodule # timeout=10
          11:19:19 > git config --get submodule.BuildFiles/***.url # timeout=10
          11:19:19 > git submodule update --init --recursive BuildFiles/***

          11:19:23 > git config --get submodule.***.url # timeout=10
          11:19:23 > git submodule update --init --recursive ***

          11:19:27 > git config --get submodule.test/***.url # timeout=10

          11:19:27 > git submodule update --init --recursive test/***

          11:19:29 FATAL: Command "git submodule update --init --recursive test/***" returned status code 1:
          11:19:29 stdout:
          11:19:29 stderr: error: pathspec 'test/***' did not match any file(s) known to git.
          11:19:29
          11:19:29 hudson.plugins.git.GitException: Command "git submodule update --init --recursive test/**" returned status code 1:
          11:19:29 stdout:
          11:19:29 stderr: error: pathspec 'test/***' did not match any file(s) known to git.

          I've traced the issue to the command "git config --get-regexp ^submodule". This is picking up the offending submodule and including it in the recursive update, despite it not being attached to the commit in question. This seems to be a problem with the Git program itself but when I do a recursive update from the command line, I don't see this issue. It seems to be attached to the process through which the Jenkins Git plugin identifies the submodules present. Would it be possible to add a check so the update does not include submodules that don't exist in the commit being targeted? I assume this will be resolved once the submodule gets merged into master but it's very inconvenient for the time being as all our follow-up builds are now failing.

          I'm not sure if this is relevant but the current branch setup has it pointed to a detached head on a specific commit. This could be impacting how the submodules are being picked up and returned.

          Thanks!
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]

          Sam Deane added a comment - - edited

          I am seeing this too.

          On the face of it, it seems to be because it's picking the list of submodules from the config with `git config --get-regexp ^submodule`.

          That's going to pick up any submodule that's ever appeared in any branch, which seems to be a fairly flawed approach.

          Perhaps I'm missing something...

          Sam Deane added a comment - - edited I am seeing this too. On the face of it, it seems to be because it's picking the list of submodules from the config with `git config --get-regexp ^submodule`. That's going to pick up any submodule that's ever appeared in any branch, which seems to be a fairly flawed approach. Perhaps I'm missing something...

          Sam Deane added a comment -

          Note that this isn't a general problem with git, it's a problem with the Jenkins implementation.

          For some reason Jenkins is using the submodule entries in the git configuration file as a way to find out about submodules. This is basically going to give you a list of all the submodules that have been used in any branch - which seems to be a strange approach to take as it leads to exactly the issue we're seeing here.

          If there's some good reason for doing it this way, then I think the code needs to be changed to allow a submodule update to quietly fail for an individual repo if that repo isn't used by the current branch.

          Sam Deane added a comment - Note that this isn't a general problem with git, it's a problem with the Jenkins implementation. For some reason Jenkins is using the submodule entries in the git configuration file as a way to find out about submodules. This is basically going to give you a list of all the submodules that have been used in any branch - which seems to be a strange approach to take as it leads to exactly the issue we're seeing here. If there's some good reason for doing it this way, then I think the code needs to be changed to allow a submodule update to quietly fail for an individual repo if that repo isn't used by the current branch.
          Mika Karjalainen made changes -
          Assignee New: Mark Waite [ markewaite ]

          markewaite seems to be developing git plugin, please could you have a look.

          Mika Karjalainen added a comment - markewaite seems to be developing git plugin, please could you have a look.
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]

          Mark Waite added a comment -

          That change of behavior was added with the git plugin 3.0.0 which added submodule authentication support. If you manually install git plugin 2.6.0 and git client plugin 1.21.0, you should see the behavior you want.

          There were authentication issues introduced in 3.0.0 which are higher priority (for me) than this issue, so it will likely be a while before I investigate this issue.

          Mark Waite added a comment - That change of behavior was added with the git plugin 3.0.0 which added submodule authentication support. If you manually install git plugin 2.6.0 and git client plugin 1.21.0, you should see the behavior you want. There were authentication issues introduced in 3.0.0 which are higher priority (for me) than this issue, so it will likely be a while before I investigate this issue.
          Mark Waite made changes -
          Link New: This issue is related to JENKINS-38860 [ JENKINS-38860 ]

            Unassigned Unassigned
            nlykins Nick Lykins
            Votes:
            9 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved: