Interpolate mirrorRepoUrl before push.
Only repository object with the name "repository" is accessible for expressions. Methods are accessed from object reflection. Method parameters and object fileds are not supported.
Example:
http://hostname/${repository.getProject().getKey()}/${repository.getName()}.git
Plugin configuration field for remote url changed to text area.
- Switched from RepositoryPushHookRequest to RepositoryHookRequest so
the MirrorRepositoryHook will be triggered after any ref change
- Added some more unit tests and logging
Using the ScheduledExecutorService is better than performing the pushes
directly in the hook method, but it still has limitations:
- Busy repositories can result in parallel pushes to the mirror (#23)
- The ScheduledExecutorService being used is a shared resources, which
can result in other callers being starved out
A better approach is to use the BucketedExecutor. It offers several
improvements that are tailor-made for the work being done here:
- Buckets can be used to control what can be done in parallel
- Tasks with the same key are grouped, and at most a single node in
a Data Center cluster can run them
- Tasks with different keys can be run in parallel
- Work can be shared among cluster nodes, in Data Center installations
- Tasks can be scheduled from one cluster node and run on another
- Locking is inherent in the BucketedExecutor's design, which means
the hook doesn't need to do any locking of its own
- This means there aren't any blocked threads.
This fixes issue #23 by ensuring at most a single push happens to any
given mirror, and by allowing the overall concurrency, even in Data
Center installations, to be controlled. (#34)
While I was making changes, because the minimum supported version for
the plugin is already Bitbucket Server 5.5, I switched the code over
to the new PostRepositoryHook SPI. This _could_ be extended to allow
the hook to respond to a wider array of events, so mirroring would be
triggered after pull request merges, branch or tag creation, etc.
However, for the sake of consistency, the current code still only
triggers pushes after other pushes. (Related to #45)
Other things:
- Added the ability to configure a timeout (#39)
- Added the ability to configure the number of retries, and the number
of BucketedExecutor threads _per cluster node_
- Added the ability to pass -Dbitbucket.test.version=5.11.1 (or any
other version) to test against a version of Bitbucket Server other
than the one being compiled against
- Marked the plugin Data Center-compatible
- Simplified wiring for DefaultPasswordEncryptor and removed the init
method from the PasswordEncryptor interface