Gerrit and Github / Stash

392 views
Skip to first unread message

Doron Shai

unread,
Oct 13, 2015, 5:16:35 AM10/13/15
to Repo and Gerrit Discussion
I learned openstack are using Gerrit for Code-review and GitHub for the git project hosting.

1. how such integration is possible from gerrit side?
2. Is it also possible to integrate with hosting on Stash?

Luca Milanesio

unread,
Oct 13, 2015, 6:30:23 AM10/13/15
to Doron Shai, Repo and Gerrit Discussion
Hi Doron,
the integration is done through the Gerrit Replication Plugin (see its configuration settings at [1]).

It works with any Git repository servers, including Stash or others.

HTH

Luca.


--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Doron Shai

unread,
Oct 13, 2015, 6:40:41 AM10/13/15
to Repo and Gerrit Discussion, doro...@gmail.com
Thanks for this information.

So if today  i have a repo on Stash and I want to enforce Code Review form now and on, so I need to:
  1. Create on Gerrit new Repository and push the original repo to it (I know how to perform the basic migration like branches, tags.... but how is the history of the original repo is kept?)
  2. Install the gerrit replication plugin as you suggested
  3. Configure the replication to replicate to the stash server on a new git repo (will be parallel to the old original repo which I will disable)
Is this correct?

Luca Milanesio

unread,
Oct 13, 2015, 7:07:06 AM10/13/15
to Doron Shai, Repo and Gerrit Discussion
Hi Doron,
you keep your Stash repo “as-is” and just make it read-only for everyone *except* the user you’ll use for Gerrit.

With the point 1, just physically copy the bare repo over to Gerrit, he will then automatically recognise it and use it :-)
After Gerrit has recognised it and used it, you may want to review / amend the security access rights through Gerrit.

Luca.

Doron Shai

unread,
Oct 13, 2015, 1:38:01 PM10/13/15
to Repo and Gerrit Discussion, doro...@gmail.com
sorry about the amount of quetions...

can you explain this step 

sudo su -c 'ssh mirror1.us.some.org echo' gerrit2

I managed to set ssh key and to connect from gerrit server to the stash server. I am not sure if this is what I was requested to do with that...

Another question, how i enable the replication plugin? it is under the plugins folder and I already placed a new file called replication.config 

Thanks,
Doron

Luca Milanesio

unread,
Oct 13, 2015, 4:59:38 PM10/13/15
to Doron Shai, Repo and Gerrit Discussion
Hi Doron,
the ssh command you quoted is for getting the remote mirror SSH public keys.

Luca.

Doron Shai

unread,
Oct 14, 2015, 1:32:18 AM10/14/15
to Repo and Gerrit Discussion, doro...@gmail.com
Hi,

I managed to create ssh connection between both servers (gerrit and Stash).

What I am unable to do now is to activate the replication plugin.

When i execute 

ssh -p 29418 name@dev-gerrit.xxx.local gerrit replication start

I get the error: 
gerrit: replication: not found

When i execute:
ssh -p 29418 name@dev-gerrit.xxx.local gerrit plugin replication load

I get the error:
gerrit plugin: replication: not found

What I configured in the replication.config is the following (different than the example because in stash the location of the repository is a folder and not "repo.git"

[remote "stash"]
    url
= stash.cloud-band.com:/opt/stash_data/data/repositories/101/
    push
= +refs/heads/*:refs/heads/*
    push = +refs/tags/*:refs/tags/*
    threads = 3
    authGroup = Public Mirror Group
    authGroup = Second Public Mirror Group

Did I missed something?

Doron

David Ostrovsky

unread,
Oct 14, 2015, 1:37:30 AM10/14/15
to Repo and Gerrit Discussion, doro...@gmail.com

Am Mittwoch, 14. Oktober 2015 07:32:18 UTC+2 schrieb Doron Shai:
Hi,

I managed to create ssh connection between both servers (gerrit and Stash).

What I am unable to do now is to activate the replication plugin.

When i execute 

ssh -p 29418 name@dev-gerrit.xxx.local gerrit replication start

I get the error: 
gerrit: replication: not found

It wouldn't hurt to install replication plugin.You can check plugin status with Gerrit plugin SSH command:

 $ ssh host gerrit plugin ls
 Name                           Version    Status   File
 replication                    v2.10-rc1-26-gaebb492 ENABLED  replication.jar

David Pursehouse

unread,
Oct 14, 2015, 1:42:55 AM10/14/15
to Doron Shai, Repo and Gerrit Discussion
On 10/14/2015 02:32 PM, Doron Shai wrote:

> When i execute
>
> |
> ssh -p 2941...@dev-gerrit.xxx.localgerrit replication start
> |
>
> I get the error:
> */gerrit: replication: not found/*
>

'replication' is not a subcommand of 'gerrit', it's a standalone
command. So you should execute:

ssh -p 29418 na...@dev-gerrit.xxx.local replication start

without the 'gerrit' command.

Doron Shai

unread,
Oct 14, 2015, 2:40:17 AM10/14/15
to Repo and Gerrit Discussion, doro...@gmail.com
Ok, now it is installed, loaded with the following configs

[remote "stash"]
    url
= stash:/opt/stash_data/data/repositories/${name}/
    push
= +refs/heads/*:refs/heads/*
    push = +refs/tags/*:refs/tags/*
    threads = 1


then I started the replication in 2 ways

ssh -p 29418 name@dev-gerrit.xxx.local replication start repoTEST
and
ssh -p 29418 name@dev-gerrit.xxx.local replication start

It seems that my configuration is wrong since there no new repository is created on the remote stash server

Doron

David Pursehouse

unread,
Oct 14, 2015, 2:41:39 AM10/14/15
to Doron Shai, Repo and Gerrit Discussion
On 10/14/2015 03:40 PM, Doron Shai wrote:
> Ok, now it is installed, loaded with the following configs
>
> |
> [remote "stash"]
> url =stash:/opt/stash_data/data/repositories/${name}/
> push =+refs/heads/*:refs/heads/*
> push = +refs/tags/*:refs/tags/*
> threads = 1
> |
>
>
> then I started the replication in 2 ways
>
> |
> ssh -p 2941...@dev-gerrit.xxx.localreplication start repoTEST
> |
> and
> |
> ssh -p 2941...@dev-gerrit.xxx.localreplication start
> |
>
> It seems that my configuration is wrong since there no new repository is
> created on the remote stash server
>

You should be able to see what's going on by looking at the
replication.log file.

Luca Milanesio

unread,
Oct 14, 2015, 3:04:12 AM10/14/15
to Repo and Gerrit Discussion, Doron Shai, David Pursehouse
Would it make sense to make a “bitbucket-plugin” similar to the GitHub plugin, so that all those operations can be easily automated?
In the past 2 years, over 7000 people benefited from a simplified GitHub authentication and repositories replication on GerritHub.io … possibly many more are waiting for the same scenario on BitBucket.

P.S. Atlassian Stash doesn’t exist anymore … everything has been now renamed to BitBucket (Stash = BitBucket Server)

Luca.

Doron Shai

unread,
Oct 14, 2015, 3:51:39 AM10/14/15
to Repo and Gerrit Discussion, doro...@gmail.com, david.pu...@sonymobile.com
sounds like a good idea, but in the meanwhile I will have to do all those operations manually.... ;)

Doug Kelly

unread,
Oct 14, 2015, 7:33:00 AM10/14/15
to Repo and Gerrit Discussion, doro...@gmail.com, david.pu...@sonymobile.com
Almost certainly.  From what I recall in Stash (ableit an older version), their repository organization on-disk is somewhat different, to allow the forking model.  I don't think you can just push to the filesystem and have Stash pick it up.  There should be an API for creating a repository...

Even though automatic repository creation may not work, you should still be able to push using SSH -- i.e. setting url to ssh://server:7999/project/${name}.git

--Doug

Doron Shai

unread,
Oct 14, 2015, 7:46:01 AM10/14/15
to Repo and Gerrit Discussion, doro...@gmail.com, david.pu...@sonymobile.com
i changed the configuration file to this:

[remote "stash"]
    url
= ssh://stash:7999/cip/${name}.git
    push
= +refs/heads/*:refs/heads/*
    push = +refs/tags/*:refs/tags/*
    authGroup = ToBeReplicatedToStash

Still when i execute replication start nothing happens....

How I can "debug" it - is there any log that I can raise?

I want to see what is actually take place...

Doron

Doug Kelly

unread,
Oct 14, 2015, 9:59:21 AM10/14/15
to Repo and Gerrit Discussion, doro...@gmail.com, david.pu...@sonymobile.com
replication.log on the gerrit server will have some idea of the actions, but you can also use "ssh gerrit -p 29418 replication start --wait --all" -- you'll get some progress output from the SSH command that way.

Doron Shai

unread,
Oct 14, 2015, 10:32:46 AM10/14/15
to Repo and Gerrit Discussion, doro...@gmail.com, david.pu...@sonymobile.com
doing it all i see is

[2015-10-14 17:25:38,793 +0300] e5a2d2af name a/1 LOGIN FROM 137.247.17.796
[2015-10-14 17:26:41,649 +0300] e5a2d2af name a/1 LOGOUT
[2015-10-14 17:26:41,656 +0300] e5a2d2af name a/1 replication.start.--wait.--all 3ms 62854ms 127
[2015-10-14 17:26:45,841 +0300] 45915e5d name a/1 LOGIN FROM 137.247.17.796
[2015-10-14 17:26:45,853 +0300] 45915e5d name a/1 replication.start.--all 3ms 3ms 0
[2015-10-14 17:26:45,887 +0300] 45915e5d name a/1 LOGOUT

Doug Kelly

unread,
Oct 14, 2015, 10:46:33 AM10/14/15
to Repo and Gerrit Discussion, doro...@gmail.com, david.pu...@sonymobile.com
OK, in your replication.config, you have a group "ToBeReplicatedToStash" referenced -- does this user group actually exist and does it have permissions to read the repository?  If not, you may want to just use "Registered Users" (this would replicate anything a registered user can see).

Also, you're looking at sshd_log; look for replication_log in the same directory.

Doron Shai

unread,
Oct 14, 2015, 10:56:49 AM10/14/15
to Repo and Gerrit Discussion, doro...@gmail.com, david.pu...@sonymobile.com
Thanks for the tip about replication_log - this is what i wanted to see...

in the log I see this error as you said:

Group "ToBeReplicatedToStash" not recognized, removing from authGroup

strange.... i do have it on the project access (See attached)
access.PNG

Doron Shai

unread,
Oct 14, 2015, 11:55:07 AM10/14/15
to Repo and Gerrit Discussion, doro...@gmail.com, david.pu...@sonymobile.com
That is it! Finally it works!

Thanks for the massive assistance from all of you :)

What did the trick are the following:

1. on etc/replication.config - i set it this way

[remote "stash"]
   push = +refs/heads/*:refs/heads/*
   push = +refs/tags/*:refs/tags/*
   authGroup = Registered Users
   threads = 1

2. on /home/gerrit2/.ssh/config

Host stash
   IdentityFile /home/gerrit2/.ssh/id_rsa
   StrictHostKeyChecking no
   UserKnownHostsFile /dev/null
   BatchMode yes

3. Login with the jenkins user to stash web UI and upload the id_rsa.pub to the SSH keys of the jenkins user

4. In stash server, go to the repo hooks folder

/opt/stash_data/data/repositories/101/hooks

5. Change the name of both pre-recive and pre-recieve.d under the target repo (otherwise you will get error about pre-receive hook declined)

mv pre-receive pre-receive.SAMPLE
mv pre-receive.d pre-receive.d.SAMPLE

6. Relaod the plugin 

ssh -p 29418 na...@dev-gerrit.ocal gerrit plugin reload replication

7. Then start the replication

ssh -p 29418 na...@dev-gerrit.ocal replication start --all

8. Enjoy!
Reply all
Reply to author
Forward
0 new messages