I\'ve spun up an instance of gerrit from the quick start guide.
My company uses BitBucket with pull requests and occasionally crucible for code reviews. We use Jenkin
Gerrit implements it's code review functionalities by providing a (more-or-less) thin wrapper around an actual Git repository that is hosted within Gerrit itself. To my knowledge, there is no possibility to integrate an external Git repository directly in Gerrit.
This means that when using Gerrit, the Git repository needs to be hosted within Gerrit itself. In consequence of that, you will need to maintain a full copy of your BitBucket repository within your Gerrit instance. So this question basically boils down to keeping two Git repositories in sync.
As you're already using Jenkins, I'd recommend a Jenkins build to update your Gerrit repository whenever new commits are pushed to the BitBucket repository. For this, you'll need:
refs/heads/*
ref in your Gerrit project. This user will be used by Jenkins. Be careful not to grant this privilege to any end-users, or they'll be able to bypass code review by pushing directly.When submitting code reviews in Gerrit, the new commits will need to be pushed back to BitBucket. Usually, I'd recommend using the replication plugin for that. Here's how a respective configuration file might look like (goes in etc/replication.config
in your Gerrit directory):
[remote "bitbucket"]
url = ssh://git@bitbucket.org/<your-user>/${name}.git
push = +refs/tags/*:refs/tags/*
push = +refs/heads/*:refs/heads/*
mirror = true
replicateOnStartup = true
replicatePermissions = false
Since you mentioned that you'd like to avoid using replication, you can also use a Jenkins job for synchronizing commits from Gerrit back to BitBucket. To minimize the delay, you can use the Gerrit Trigger plugin for Jenkins (which you'll want to be using anyway for your pre-commit checks). Alternatively, you can use a custom Gerrit hook that you place in hooks/ref-updated
to trigger a Jenkins build (drop a comment if you'd like me to elaborate on that).
Hope this helps!