Home > Blockchain >  Clone git with submodule using github access token in Jenkins
Clone git with submodule using github access token in Jenkins

Time:10-05

I have a github app which invoke Jenkins pipeline every time we push new branch into github repo. We create access token using github's /api/v3/app/installations/${payload_installation_id}/access_tokens url.

I am able to clone the root repository using https://x-access-toekn:/github.com just fine, but one of the repositories has submodules with ssh url. Trying to update those submodules fails.

How can I get those submodules to clone as well using the access token?

I tried to create a .gitconfig with

[url http://x-access-toekn:[email protected]]
  insteadOf = [email protected]:

but that doesn't seems to work.

CodePudding user response:

Run

git config url.http://x-access-toekn:[email protected]/.insteadOf [email protected]:

This changes the section to

[url "http://x-access-toekn:[email protected]/"]
    insteadOf = [email protected]:

Please note a slash / at the end. The section replaces [email protected]:user/repo.git with correct http://x-access-toekn:[email protected]/user/repo.git, not with incorrect http://x-access-toekn:[email protected]/repo.git (error in github.comuser).

  • Related