5

We have approx 1000 repositories on bitbucket. I have decided to put our repositories on our local server. Hence I have installed Gitlab on local server and integrate it with bitbucket from following link. http://docs.gitlab.com/ce/integration/bitbucket.html

Now, I can easily import repositories from bitbucket to gitlab. Now, I want that any changes in repositories(push, tag, branch) in gitlab will automate it to bitbucket without any clone in local server.

I have checked Gitlab-CI but not worked. http://abhipandey.com/2015/09/automated-git-mirror-with-github-or-gitlab-or-bitbucket/

Sud
  • 121
  • 1
  • 1
  • 4

1 Answers1

3

If you can upgrade to GitLab 8.7 (May 2016), this feature (mirorring to an external repo from GitLab) is now available.

See "Feature highlight: Push to a remote repository"

It can be configured in Settings → Mirror Repository

enter image description here

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @Sud true, you would need to use it on a repo hosted by gitlab.com, the free SaaS version of GitLab EE. So it is not for any repo. – VonC May 28 '16 at 14:40
  • I just get error from that. "repository access denied. deployment key is not associated with the requested repository. fatal: Could not read from remote repository." Does this actually work? What deployment key is it talking about? – user988346 Oct 05 '17 at 11:17
  • @user988346 that means you are using an ssh URL, right? Not an https one? – VonC Oct 05 '17 at 11:46
  • Ya, do I need to be using https? – user988346 Oct 05 '17 at 11:49
  • @user988346 If you want to avoid using a deploy (SSH) key, yes. If not, see https://stackoverflow.com/a/43308324/6309 – VonC Oct 05 '17 at 11:52
  • @VonC So gitlab needs to connect to bitbucket to push code right? It looks like that post is putting a public key in gitlab and a private key into jenkins. In this case I would need gitlab to control a private key and I would need to associate a public key with my user in bitbucket (because I can't put it on the project itself with write access). I see the deploy keys interface in gitlab. Can I upload the private key there? It asks if this key should be given write access to the gitlab project. I don't think this is correct. – user988346 Oct 05 '17 at 12:16
  • @user988346 then use an https URL: that seems easier ;) – VonC Oct 05 '17 at 12:17
  • Wouldn't I need a username and password? Usually I'm prompted for that stuff when I use https locally but I guess I could try to just copy/paste my credentials into the URL where you usually put basic auth stuff. I kind of don't think this mirroring feature is set up all that well.. I kind of doubt it works at all. – user988346 Oct 05 '17 at 12:55
  • @user988346 Not if you are using a credential.helper (https://git-scm.com/docs/gitcredentials). On Windows, it would use the Windows Credential Manager. That will cache your credential and won't ask them again. – VonC Oct 05 '17 at 13:44
  • I found that they haven't implemented support for pushing over ssh yet. https://gitlab.com/gitlab-org/gitlab-ee/issues/3251 I think what I'll do is try to get pull working and do all my pushing to where I was trying to get gitlab to push to.. What I could do is check which public key they attempt to push with but it's global across the whole site.. so someone else would be able to push to the same place so that's a bad idea. Anyway.. thanks for all the help. Maybe I'll try the https approach later. – user988346 Oct 06 '17 at 06:46
  • 2
    I found one needs to use Bitbucket's app-specific password for https auth, not one's login password. Create under your account on BB. – hoopyfrood Oct 04 '18 at 20:01
  • 2
    Bitbucket app-specific password with permissions repos=rw is enough. – rshev Sep 03 '19 at 16:11