Git Submodule Could Not Read From Remote Repository

Problem

Plan build fails if a plan checks out a Bitbucket Server or Deject repository that contains git submodules (if submodules are enabled in advanced repository settings in Bamboo).

Symptoms

You will discover authentication errors in plan build logs. If the submodule has been declared using an SSH Git URL:

Repository non found The requested repository does not exist, or you lot do not have permission to access information technology. fatal: Could not read from remote repository.

Or, if Git  submodule has been added with https URL:

fatal: Hallmark failed for 'https://bitbucket-server.com/scm/vpe/adat.git/' fatal: clone of 'https://bitbucket-server.com/scm/scm/vpe/adat.git' into submodule path '/opt/data/bamboo/xml-information/build-dir/MTP-MT-JOB1/submodule' failed

Cause

Bamboo tries to checkout submodules but fails because it does not have username/password (for https URLs) or SSH primal (for SSH Git URLs). In case of submodules  the clone happens exterior of Bamboo SSH proxy.

Solution

There are two solutions to this trouble . The first solution implies changes to .gitmodules file and adding SSH key to repository settings. The second one is all almost configuring SSH keys (or passwordless access for https repositories) on all agent nodes.

Option ane: Apply Relative Paths

 ane. To forcefulness Bamboo use SSH proxy, use relative paths instead of https or ssh Git URLs.

The following .gitmodules

[submodule "module1"]
path = submodule1
url = ssh://git@bitbucket-server.com:7999/project1/repo1.git
[submodule "submodule2"]
path = submodule2
url = ssh://git@bitbucket-server.com:7999/project1/repo2.git

Should become:

[submodule "module1"]
path = submodule1
url = ../repo1.git
[submodule "submodule2"]
path = submodule2
url = ../repo2.git

In this particular example the relative path is ../repo1 and ../repo2, thus we assume that the main repo is in the aforementioned Bitbucket project. If Bitbucket projects are dissimilar, a relative path should look like this:

../../projectName/repo.git

2. Having replaced URLs with relative paths, a public SSH key needs to be added to submodule repositories in Bitbucket.

Copy SSH key from the avant-garde settings of the main repository in Bamboo:

Salvage this primal as Access Token in Bitbucket Server repository settings:

For Bitbucket Cloud y'all may skip Footstep 2 if you have already uploaded private key to Bamboo and added a public cardinal to your profile when adding the main repository to a programme.

Pick #2: Apply Absolute URLs

If for some reason changes to .gitmodules are non possible and either https or ssh URLS are used, agent environments need to be configured to let Git clone the repositories without countersign prompts. Depending on the URL and the Bone instructions vary.

Configuration needs to exist performed on all remote agent machines (and Bamboo server machine likewise if local agents are used).

Linux: HTTPS

repeat "https://admin:password@git.mybitbucket.com" > ~/.git-credentials

The downside of this approach is that credentials are store in a plan text file which isn't secure. Also, this command needs to be run on all new agent machines (unless the job that uses Git repo with submodules has dedicated agents)

Linux: SSH

Either generate or re-create id_rsa to ~/.ssh. Make certain the .ssh directory permissions are 700 (drwx------) and the private key (id_rsa) is 600 (-rw-------). Exercise not forget to add a public central as an access token to Bitbucket repository settings or user contour.

Again, the downside here is that a private fundamental is stored on agent machines, and it needs to be copied to any new agent machines (unless dedicated agents are used).

Windows: HTTPS

At that place are two options here:

  • use _netrc file
  • recommended - use Git Credential Managing director. Make sure GCM_INTERACTIVE is prepare to Never.

Windows: SSH

Follow instructions for Linux users. File and directory permission bug are possible. You may demand to manually clone the repository to troubleshoot such problems.

lyleshawat.blogspot.com

Source: https://confluence.atlassian.com/bamkb/bitbucket-server-and-cloud-repositories-with-git-submodules-1026524045.html

0 Response to "Git Submodule Could Not Read From Remote Repository"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel