不工作:GitBlit groovy钩子推到其他Gitblit服务器回购 [英] Not working: GitBlit groovy hook which push changed to other Gitblit server repo

查看:735
本文介绍了不工作:GitBlit groovy钩子推到其他Gitblit服务器回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


需要一个将你的Gitblit实例的变化推送到另一个
Gitblit实例的groovy push hook脚本


我有两个私人的 linux服务器,说 A B GitBlit 安装在两者上。所有开发人员在服务器 A 上提交并推送其更改,我希望 B A 。



A ssh:// admin @ serverA:29418 / testrepo.git



最初,我从 testrepo 服务器 A B 使用linux scp命令



B ssh:// admin @ serverB:29418 / testrepo.git $ b preush $ c $ push $ g code $:$ $ $ $ $ $ $ $ p> import com.gitblit.GitBlit
import com.gitblit.Keys
import com.gitblit.models.RepositoryModel
import com.gitblit.models.TeamModel
import com.gitblit.models.UserModel
import com.gitblit.utils.JGitUtils
import com.gitblit.utils.StringUtils
import java.text.SimpleDateFormat
import org.eclipse.jgit.api.CloneCommand
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.lib.Repository
import org.eclipse.jgit.lib。 CONFI g
import org.eclipse.jgit.revwalk.RevCommit
import org.eclipse.jgit.transport.ReceiveCommand
import org.eclipse.jgit.transport.ReceiveCommand.Result
import org.eclipse.jgit.util.FileUtils
import org.slf4j.Logger

文件baseFolder = GitBlit.getFileOrFolder(Keys.git.repositoriesFolder)
文件repoFolder = new File( baseFolder,repository.name);
git git = git.open(repoFolder,FS.detect())
git.push()。setRemote(ssh:// admin @ serverB:29418 / testrepo.git).setPushAll )。呼叫();

我已经使用Gitblit UI添加了此脚本



testresopistory.git>编辑>接收>后接收脚本>选择(pushserver)



服务器重新启动:
现在当我要推送 serverA上的文件时那么为什么这个脚本不会将更改推送到 serverB

解决方案 div>

感谢詹姆斯 - 莫格



干杯!! :)它使用 pushhook

  import com.gitblit.GitBlit 
import com.gitblit.Keys
import com.gitblit.models.RepositoryModel
import com.gitblit.models.TeamModel
import com.gitblit.models.UserModel
import com.gitblit.utils.JGitUtils
import com.gitblit.utils.StringUtils
import java.text.SimpleDateFormat
import org.eclipse.jgit.api.CloneCommand
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.lib.Repository
import org.eclipse.jgit.lib.Config
import org.eclipse.jgit.revwalk.RevCommit
import org.eclipse.jgit.transport.ReceiveCommand
import org.eclipse.jgit。 transport.ReceiveCommand.Result
import org.eclipse.jgit.util.FileUtils
import org.eclipse.jgit.util.FS
import org.slf4j.Logger


logger.info(*************** START CUSTOM PUSH *******************)

文件baseFolder =新建文件(/ root / softwares / apache-tomcat-6.0.32 / webapps / gitblit / WEB-INF / data / git);
文件repoFolder =新建文件(baseFolder,repository.name);
git git = Git.open(repoFolder,FS.detect())
git.push()。setRemote(ssh://admin@111.11.111.111:29418 / testrepo.git)。 setPushAll()()调用。


logger.info(*************** DONE CUSTOM PUSH *************** ****)


Need a groovy push hook scripts which push changes 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.

A : ssh://admin@serverA:29418/testrepo.git

Initially I have copied testrepo from server A to B using linux scp command

B : ssh://admin@serverB:29418/testrepo.git

pushserver.groovy :

import com.gitblit.GitBlit
import com.gitblit.Keys
import com.gitblit.models.RepositoryModel
import com.gitblit.models.TeamModel
import com.gitblit.models.UserModel
import com.gitblit.utils.JGitUtils
import com.gitblit.utils.StringUtils
import java.text.SimpleDateFormat
import org.eclipse.jgit.api.CloneCommand
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.lib.Repository
import org.eclipse.jgit.lib.Config
import org.eclipse.jgit.revwalk.RevCommit
import org.eclipse.jgit.transport.ReceiveCommand
import org.eclipse.jgit.transport.ReceiveCommand.Result
import org.eclipse.jgit.util.FileUtils
import org.slf4j.Logger

File baseFolder = GitBlit.getFileOrFolder(Keys.git.repositoriesFolder)
File repoFolder = new File(baseFolder, repository.name);
Git git = Git.open(repoFolder, FS.detect())
git.push().setRemote("ssh://admin@serverB:29418/testrepo.git").setPushAll().call();

I have added this script using Gitblit UI

testresopistory.git> edit> receive> post-receive scripts> selected(pushserver)

Server restarted : Now when I am going to push a file on serverA then why this script not push changes to serverB ?

解决方案

Thanks to james-moger

Cheers!! :) It's working with pushhook

import com.gitblit.GitBlit
import com.gitblit.Keys
import com.gitblit.models.RepositoryModel
import com.gitblit.models.TeamModel
import com.gitblit.models.UserModel
import com.gitblit.utils.JGitUtils
import com.gitblit.utils.StringUtils
import java.text.SimpleDateFormat
import org.eclipse.jgit.api.CloneCommand
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.lib.Repository
import org.eclipse.jgit.lib.Config
import org.eclipse.jgit.revwalk.RevCommit
import org.eclipse.jgit.transport.ReceiveCommand
import org.eclipse.jgit.transport.ReceiveCommand.Result
import org.eclipse.jgit.util.FileUtils
import org.eclipse.jgit.util.FS
import org.slf4j.Logger


logger.info("*************** START CUSTOM PUSH *******************")

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();


logger.info("*************** DONE CUSTOM PUSH*******************")

这篇关于不工作:GitBlit groovy钩子推到其他Gitblit服务器回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆