Merging and pushing to remote repository fails

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

You are using a custom workflow that includes merging/pushing with/to a remote branch.

Why it won't work out of the box

Bamboo creates Git workspaces copying a minimal set of data:

git init
git fetch <remote-branch-ref>:<local-branch-ref>

This way Bamboo copies only a branch that should be build. Side effect of this is that workspace is not a full clone with information about all branches.

Moreover Bamboo uses repository caching. It means that code is first fetched from remote repository to a local cache and then another fetch is made from this cache to a workspace that is placed in Plan's working directory. Thus said even if clone operations were performed instead of init/fetch combo we'd be still pushing to a remote which would actually be a local cache instead of real remote repository.

The solution is to:

1- add reference to remote repository to a local workspace (via Script task executed after source checkout task)

git remote add <repository-id> <repository-url>

2- add missing branches (probably in the same script as previous command)

git fetch <repository-id> +<remote-branch-ref>:<local-branch-ref>

3- and finally push to a new branch

git push <repository-id> <local-branch-ref>:<remote-branch-ref>
Last modified on Jun 27, 2013

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.