Gerrit - Replicating to github

♀尐吖头ヾ 提交于 2019-12-06 07:34:11

问题


I configured gerrit replication via

[remote "github"]
  url = git@github.com:MYUSERNAME/${name}.git
  push = +refs/heads/*:refs/heads/*
  push = +refs/tags/*:refs/tags/*
  timeout = 5
  replicationDelay = 0
  authGroup = Administrators

I can log in to github with the gerrit2 user as far as it is allowed from github site. Github is in the known hosts. However I get the following error:

[2013-06-04 20:04:54,472] ERROR com.googlesource.gerrit.plugins.replication.ReplicationQueue : Cannot replicate to git@github.com:MYUSERNAME/All-Projects.git
org.eclipse.jgit.errors.TransportException: git@github.com:MYUSERNAME/All-Projects.git: reject HostKey: github.com
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:142)
    at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
    at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
    at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
    at com.googlesource.gerrit.plugins.replication.PushOne.listRemote(PushOne.java:409)
    at com.googlesource.gerrit.plugins.replication.PushOne.doPushAll(PushOne.java:357)
    at com.googlesource.gerrit.plugins.replication.PushOne.generateUpdates(PushOne.java:350)
    at com.googlesource.gerrit.plugins.replication.PushOne.pushVia(PushOne.java:298)
    at com.googlesource.gerrit.plugins.replication.PushOne.runImpl(PushOne.java:252)
    at com.googlesource.gerrit.plugins.replication.PushOne.runPushOperation(PushOne.java:207)
    at com.googlesource.gerrit.plugins.replication.PushOne.access$000(PushOne.java:71)
    at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:186)
    at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:183)
    at com.google.gerrit.server.util.RequestScopePropagator$5.call(RequestScopePropagator.java:222)
    at com.google.gerrit.server.util.RequestScopePropagator$4.call(RequestScopePropagator.java:201)
    at com.google.gerrit.server.git.PerThreadRequestScope$Propagator$1.call(PerThreadRequestScope.java:75)
    at com.googlesource.gerrit.plugins.replication.PushOne.run(PushOne.java:183)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
    at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:337)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: com.jcraft.jsch.JSchException: reject HostKey: github.com
    at com.jcraft.jsch.Session.checkHost(Session.java:712)
    at com.jcraft.jsch.Session.connect(Session.java:313)
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
    ... 25 more

Similar problem for ssh access with

url = ssh://git@ssh.github.com:443/MYUSERNAME/${name}.git

[2013-06-04 21:22:06,072] ERROR com.googlesource.gerrit.plugins.replication.ReplicationQueue : Cannot replicate to ssh://git@ssh.github.com:443/MYUSERNAME/All-Projects.git
org.eclipse.jgit.errors.TransportException: ssh://git@ssh.github.com:443/MYUSERNAME/All-Projects.git: reject HostKey: ssh.github.com
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:142)
    at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
    at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
    at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
    at com.googlesource.gerrit.plugins.replication.PushOne.listRemote(PushOne.java:409)
    at com.googlesource.gerrit.plugins.replication.PushOne.doPushAll(PushOne.java:357)
    at com.googlesource.gerrit.plugins.replication.PushOne.generateUpdates(PushOne.java:350)
    at com.googlesource.gerrit.plugins.replication.PushOne.pushVia(PushOne.java:298)
    at com.googlesource.gerrit.plugins.replication.PushOne.runImpl(PushOne.java:252)
    at com.googlesource.gerrit.plugins.replication.PushOne.runPushOperation(PushOne.java:207)
    at com.googlesource.gerrit.plugins.replication.PushOne.access$000(PushOne.java:71)
    at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:186)
    at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:183)
    at com.google.gerrit.server.util.RequestScopePropagator$5.call(RequestScopePropagator.java:222)
    at com.google.gerrit.server.util.RequestScopePropagator$4.call(RequestScopePropagator.java:201)
    at com.google.gerrit.server.git.PerThreadRequestScope$Propagator$1.call(PerThreadRequestScope.java:75)
    at com.googlesource.gerrit.plugins.replication.PushOne.run(PushOne.java:183)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
    at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:337)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: com.jcraft.jsch.JSchException: reject HostKey: ssh.github.com
    at com.jcraft.jsch.Session.checkHost(Session.java:712)
    at com.jcraft.jsch.Session.connect(Session.java:313)
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
    ... 25 more

回答1:


Log in (via SSH) as the user under which Gerrit is running.

I recommend you to set up a ~/.ssh/config for the Gerrit user like this:

Host github.com
    User git
    IdentityFile /path/to/the/private/key
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

This sets up your SSH key ignores warnings about the (initially) unknown host.

If you can then connect via ssh github.com, we're almost there. Then try to clone the Github repository using the SSH URL.

Afterwards let Gerrit try to replicate again.

Plus then I would recommend to remove the authGroup setting from the replication.config.




回答2:


Create a group "Github Export" and give this group read access only to the repos you want to export (or explicitly deny read access for All-Projects, which is kind of a meta project carrying only settings inherited by other projects). When you then set the authGroup = Github Export, only repos to which this group has access are exported.

Please keep in mind that since Gerrit 2.5 the group has to be visible to all members (it's a setting of the group), caused by extracting that functionality into a plugin. See the Gerrit list archive for that.

One other idea might be to use this not yet merged patch, which allows you to set patterns for what repos you want to replicate to a certain remote.

The last option would be to simply ignore this error message. Replication of other repos can still work fine.



来源:https://stackoverflow.com/questions/16924985/gerrit-replicating-to-github

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!