Jenkins, fetch git submodule over ssh with multiple users? Jenkins, fetch git submodule over ssh with multiple users? jenkins jenkins

Jenkins, fetch git submodule over ssh with multiple users?


There is a good solution I found at another question on StackOverflow: Git submodule URL not including username?

You can use

[submodule foosub]path = foosuburl = ./../foosub

To define an URL relative to the one that is being used for the project. For example, if you have your Project URL myuser@myserver.com/git/project and your Submodule URL myuser@myserver.com/git/foosub, the configuration should work. Of course, it cannot work if the submodule lies on a different server than the project.

Now Jenkins should apply its own user data to the submodule because it has its own user data set in the project URL.


If the generic Jenkins ssh "account" is authorized to at least pull from those submdules, then you could add a script which will:

  • detect it is running in a Jenkins environment
  • detect the content of the .gitmodules file
  • change the content of the .gitmodules in order to replace any user by the Jenkins one

You can also have another script which would restore the original content of the .gitmodules file, in order to not record any modification on it.

The way those scripts would automatically work would be through a content filter driver:

content filter driver


The solution was to alter the ssh config file for our Jenkins user to use it's own default user when setting up a ssh connection towards the submodule repository.