3

Need a groovy push hook scripts from your Gitblit instance to another Gitblit instance

I have two private linux servers, Say A and B with GitBlit install on both. All developers do commit and push their changes on server A, I want B keep in sync with A.

There is some Groovy hook but I am totally new in this, Can any one help to provide it.

PS: If There any push event found on A some script will fire and it push changes to B

HybrisHelp
  • 5,518
  • 2
  • 27
  • 65

2 Answers2

2

Why don't you setup B to be a mirror of A?

James Moger
  • 1,721
  • 12
  • 12
  • Both repository are private not public, As per document `you can Clone the external public repository as a mirror` – HybrisHelp May 12 '15 at 03:37
  • If I configure federation then Do I need to deal with SSH nd all or federation will take care of it? – HybrisHelp May 12 '15 at 12:28
  • 1
    I'm pretty sure federation only uses the http/https transport. This is a different mechanism than the standard mirror implementation. – James Moger May 12 '15 at 16:56
  • under `Federation Proposals (Origin Gitblit Instance)` section see step2 `Select and click the propose link for the appropriate token on the federation page`, I can not find `propose link` anywere even I login using admin/admin rights – HybrisHelp May 13 '15 at 08:12
  • 1
    A = origin. B = pulling. Skip using the web ui, configure it manually.http://gitblit.com/federation.html#H22 – James Moger May 13 '15 at 11:55
  • is Goovy push script not fulfill my requirement ?, Can you please help me to write groovy push script for this. – HybrisHelp May 18 '15 at 09:47
  • 1
    Just the repository changes. – James Moger May 20 '15 at 15:58
  • Thanks!, I have put my effor here can you please look into http://stackoverflow.com/q/30365265/2478134 – HybrisHelp May 21 '15 at 05:34
2

Thanks james-moger.

Base on my answer below are the snap of script.

File baseFolder = new File("/root/softwares/apache-tomcat-6.0.32/webapps/gitblit/WEB-INF/data/git");
File repoFolder = new File(baseFolder, repository.name);
Git git = Git.open(repoFolder, FS.detect())
git.push().setRemote("ssh://admin@111.11.111.111:29418/testrepo.git").setPushAll().call();
Community
  • 1
  • 1
HybrisHelp
  • 5,518
  • 2
  • 27
  • 65