Bamboo submodule checkout
Asked by Pawel Kasprowicz:

Hello

I have a problem with checkout git submodule.

I have two repositories on Bamboo. In both checked options:

* *Enable repository caching on remote agents*
* *Use submodules*
* *Verbose logs*

I use BitBucket 5.12 and Bamboo 6.6.2

```
simple 22-Feb-2019 12:04:40 Cloning into '/app/bamboo_5_4_1/bamboo.home/xml-data/build-dir/AD-SSHTES-JOB1/documentation'...
simple 22-Feb-2019 12:04:40 done.
simple 22-Feb-2019 12:04:40 /usr/bin/git show-ref master
simple 22-Feb-2019 12:04:40 /usr/bin/git checkout -f master
simple 22-Feb-2019 12:04:40 Already on 'master'
simple 22-Feb-2019 12:04:40 /usr/bin/git remote set-url origin ssh://asdf@127.0.0.1:10534/indala/documentation.git
simple 22-Feb-2019 12:04:40 /usr/bin/git submodule update --init --recursive
simple 22-Feb-2019 12:04:40 Submodule 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda' (ssh://BB-adress:7999/indala/camunda.git) registered for path 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda'
simple 22-Feb-2019 12:04:40 Cloning into 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda'...
simple 22-Feb-2019 12:04:40 Warning: Permanently added '[BB-adress]:7999,[10.136.106.12]:7999' (RSA) to the list of known hosts.
simple 22-Feb-2019 12:04:40 Repository not found
simple 22-Feb-2019 12:04:40 The requested repository does not exist, or you do not have permission to access it.
simple 22-Feb-2019 12:04:40 fatal: Could not read from remote repository.
simple 22-Feb-2019 12:04:40 
simple 22-Feb-2019 12:04:40 Please make sure you have the correct access rights
simple 22-Feb-2019 12:04:40 and the repository exists.
simple 22-Feb-2019 12:04:40 Clone of 'ssh://BB-adress:7999/indala/camunda.git' into submodule path 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda' failed
error 22-Feb-2019 12:04:40 Checkout to revision 8e97f65f16a073b916fc41ce8c65bc8c3324cbd3 has failed.
simple 22-Feb-2019 12:04:40 /usr/bin/git remote set-url origin file:///app/bamboo_5_4_1/bamboo.home/xml-data/build-dir/_git-repositories-cache/0edd6da93848cd44d29f4ea155f7aa4771e89f0e
error 22-Feb-2019 12:04:40 Error occurred while running Task 'Checkout Default Repository(1)' of type com.atlassian.bamboo.plugins.vcs:task.vcs.checkout.
error 22-Feb-2019 12:04:40 java.lang.RuntimeException: com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.executor.RetryingTaskExecutor.rerun(RetryingTaskExecutor.java:141)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.executor.RetryingTaskExecutor.runTask(RetryingTaskExecutor.java:99)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.executor.RetryingTaskExecutor.retry(RetryingTaskExecutor.java:207)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.executor.RetryingTaskExecutor.retry(RetryingTaskExecutor.java:188)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask.execute(VcsCheckoutTask.java:123)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$3(TaskExecutorImpl.java:288)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:221)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:288)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.task.TaskExecutorImpl.executePreparationTasks(TaskExecutorImpl.java:90)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.build.pipeline.tasks.PrepareBuildTask.call(PrepareBuildTask.java:81)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:203)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:175)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:122)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:185)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:117)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:126)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)
error 22-Feb-2019 12:04:40 at java.lang.Thread.run(Thread.java:745)
error 22-Feb-2019 12:04:40 Caused by: com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.stash.v2.BitbucketServerWorkingCopyManager.retrieveSourceCode(BitbucketServerWorkingCopyManager.java:88)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask.fillWorkingDirFromVcs(VcsCheckoutTask.java:206)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask.access$000(VcsCheckoutTask.java:54)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask$1.call(VcsCheckoutTask.java:126)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask$1.call(VcsCheckoutTask.java:123)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.executor.RetryingTaskExecutor.rerun(RetryingTaskExecutor.java:112)
error 22-Feb-2019 12:04:40 ... 20 more
error 22-Feb-2019 12:04:40 Caused by: com.atlassian.bamboo.repository.RepositoryException: Checkout to revision 8e97f65f16a073b916fc41ce8c65bc8c3324cbd3 has failed.command [/usr/bin/git submodule update --init --recursive] failed with code 1. Working directory was [/app/bamboo_5_4_1/bamboo.home/xml-data/build-dir/AD-SSHTES-JOB1/documentation]., stderr:
error 22-Feb-2019 12:04:40 Submodule 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda' (ssh://BB-adress:7999/indala/camunda.git) registered for path 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda'
error 22-Feb-2019 12:04:40 Cloning into 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda'...
error 22-Feb-2019 12:04:40 Warning: Permanently added '[BB-adress]:7999,[10.136.106.12]:7999' (RSA) to the list of known hosts.
error 22-Feb-2019 12:04:40 Repository not found
error 22-Feb-2019 12:04:40 The requested repository does not exist, or you do not have permission to access it.
error 22-Feb-2019 12:04:40 fatal: Could not read from remote repository.
error 22-Feb-2019 12:04:40 Please make sure you have the correct access rights
error 22-Feb-2019 12:04:40 and the repository exists.
error 22-Feb-2019 12:04:40 Clone of 'ssh://BB-adress:7999/indala/camunda.git' into submodule path 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda' failed
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.git.NativeGitOperationHelper.checkout(NativeGitOperationHelper.java:473)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.git.v2.GitWorkingCopyManager.lambda$checkout$0(GitWorkingCopyManager.java:232)
error 22-Feb-2019 12:04:40 at io.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:293)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.git.v2.GitWorkingCopyManager.checkout(GitWorkingCopyManager.java:212)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.git.v2.GitWorkingCopyManager.retrieveSourceCode(GitWorkingCopyManager.java:74)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.stash.v2.BitbucketServerWorkingCopyManager.retrieveSourceCode(BitbucketServerWorkingCopyManager.java:78)
error 22-Feb-2019 12:04:40 ... 25 more
error 22-Feb-2019 12:04:40 Caused by: com.atlassian.bamboo.plugins.git.GitCommandException: command [/usr/bin/git submodule update --init --recursive] failed with code 1. Working directory was [/app/bamboo_5_4_1/bamboo.home/xml-data/build-dir/AD-SSHTES-JOB1/documentation]., stderr:
error 22-Feb-2019 12:04:40 Submodule 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda' (ssh://BB-adress:7999/indala/camunda.git) registered for path 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda'
error 22-Feb-2019 12:04:40 Cloning into 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda'...
error 22-Feb-2019 12:04:40 Warning: Permanently added '[BB-adress]:7999,[10.136.106.12]:7999' (RSA) to the list of known hosts.
error 22-Feb-2019 12:04:40 Repository not found
error 22-Feb-2019 12:04:40 The requested repository does not exist, or you do not have permission to access it.
error 22-Feb-2019 12:04:40 fatal: Could not read from remote repository.
error 22-Feb-2019 12:04:40 Please make sure you have the correct access rights
error 22-Feb-2019 12:04:40 and the repository exists.
error 22-Feb-2019 12:04:40 Clone of 'ssh://BB-adress:7999/indala/camunda.git' into submodule path 'src/docs/asciidoc/modules/dac_intro/examples/src/camunda' failed
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:704)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:633)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:624)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runSubmoduleUpdateCommand(GitCommandProcessor.java:392)
error 22-Feb-2019 12:04:40 at com.atlassian.bamboo.plugins.git.NativeGitOperationHelper.checkout(NativeGitOperationHelper.java:459)
error 22-Feb-2019 12:04:40 ... 30 more
```

And this is strange, because when I checkout without submodule I don't have any problems, but when I add submodule I have:

```
error 22-Feb-2019 12:04:40 Warning: Permanently added '[BB-adress]:7999,[10.136.106.12]:7999' (RSA) to the list of known hosts.
error 22-Feb-2019 12:04:40 Repository not found
error 22-Feb-2019 12:04:40 The requested repository does not exist, or you do not have permission to access it.
error 22-Feb-2019 12:04:40 fatal: Could not read from remote repository.
error 22-Feb-2019 12:04:40 Please make sure you have the correct access rights
error 22-Feb-2019 12:04:40 and the repository exists.
```

But Applinks and ssh keys works fine.

Thank you in advice

Pawel


Answers:
author: Foong
body: Submodule function does not work well yet <https://jira.atlassian.com/browse/BAM-11369>

The SSH key inside the remote agent machine have to be uploaded to Bitbucket Server.

comments: author: Pawel Kasprowicz
body: Thanks for information. I will check this.


author: yogesh_devi
body: I have similar problem. I use git submodules and submodule update is failing .From command line on bamboo agent I can see prompts for password. I am still trying to figure how to set password less auth . When I attempt to add the public key of user (that runs bamboo from my agent) to bitbucket, then i get a message from bitbucket "This SSH key is already assigned to 'bamboo'". The git clone is failing in my case as the agent is attempting to clone from local cache and Bamboo does not seem to provide an option to turn the local caching off. In Bamboo newer versions ( I have [an Bamboo](http://www.atlassian.com/software/bamboo/) version 6.8.1) There is a checkbox in "Advanced" section of repository settings that reads "Enable repository caching on remote agents" . However as per my observation bamboo disregards whether you check on not check it and caches on the remote agents anyways :-(


Tags: bitbucket

bitbucket-server

git

server