4

I have a project that spins up EC2 instances as build slaves, the username is "ec2-user".

I am checking out a repository with submodules like this:

checkout([
          $class: 'GitSCM',
          branches: [[name: 'deadbeefdeadbeefcafebabe']],
          doGenerateSubmoduleConfigurations: false,
          extensions: [
             [$class: 'SubmoduleOption',
              disableSubmodules: false,
              parentCredentials: true,
              recursiveSubmodules: true,
              reference: '',
              trackingSubmodules: false]
          ], submoduleCfg: [],
          userRemoteConfigs: [
             [credentialsId: 'deadbeef-cafe-babe-cafe-babebeef1234',
              refspec: 'refs/changes/12/34567/89',
              url: 'ssh://user@host:29418/some/project']
          ]
])

Please note that the URL has a username.

Now, the .gitmodules file looks like this:

[submodule "path/in/project"]
    path = path/in/project
    url = ssh://host:29418/other/project
    branch = somebranch

The submodule description does not have a username specified. When it is time for the submodule clone, the clone is denied with invalid credentials. Manually editing the .gitmodules file and adding the user@ in front of the URL works, but this is a bad workaround at best. Changing the URL on disk and then calling checkout again does also not work.

How can I make Jenkins use the username it used in the parent checkout? If that is not possible, what is a workaround which does not involve changing the source repo?

wonderb0lt
  • 2,035
  • 1
  • 23
  • 37
  • My current workaround: Manipulate the executing slave to use a specific username for the host using [ssh config](http://stackoverflow.com/a/10197697/660848) – wonderb0lt Oct 28 '16 at 11:56

0 Answers0