Jenkins Git change submodule path

Is there a way to change the submodule path to pull from a different repository during build time?

  • Git workflow for multiple projects based on my own seed project?
  • git add -i keeps returning perl no user error on Mac OSX Lion
  • Git push over HTTP (not HTTPS) on Ubuntu hangs after sending files
  • How do I do automatic tracking of filename changes with GIT?
  • Finding the SHA1's of all objects in a commit git
  • vscode quick open “git checkout” shows no results
  • Sourcetree 2.1.2.5 - Shows “Uncommitted changes” yet nothing is pending
  • GitLab: Can't push code to server?
  • How do I move my local Git repository to a remote Git repository
  • Git - recover intermediate commits after squash
  • How to remove a filter from Git
  • Git workflow issue. Remove a merged branch from another branch
  • One Solution collect form web for “Jenkins Git change submodule path”

    Submodule URLs are set in the .gitmodules file in your repo, so you just need to modify the URL within that file.

    git-config accepts a -f argument indicating the config file, which you can use to specify the .gitmodules file instead of the normal .git/config or ~/.gitconfig files which are normally used. Using this option, you could modify the submodule URL with the following:

    git config -f .gitmodules submodule.<submodule name>.url <new URL>
    

    Or, you could manually modify the submodule’s URL in the .gitmodules file to the changed path. A shell script phase prior to your build phase in Jenkins could accomplish modifying that file, and if necessary you could git checkout -- . afterward to restore the original URL.

    Either way, you’ll want to run git submodule sync afterward to reflect the change in the containing repo.

    Git Baby is a git and github fan, let's start git clone.