Chapter 3. Repository Hooks
In Business Central, it is possible to trigger a chosen action every time a particular event happens. For this purpose, you can configure the repository to use scripts called hooks.
3.1. Configuring Git Hooks
Business Central can automatically push changes to a remote repository using the Git hooks. Git hooks support has been introduced with the release of Red Hat JBoss BPM Suite 6.2.0.
Note
Please note that currently only the
post-commit
hook is supported. Post-commit
hooks are triggered after finishing the entire commit process.
The following procedure shows how to configure the
post-commit
hook to automatically push your changes to the remote repository.
- In Business Central, go to Authoring → Administration.
- Below the main menu, click Repositories → Clone repository.
- In the displayed Clone repository dialog box, fill in the repository information:
- Repository Name
- Organizational Unit
- Git URL: for example
https://github.com/USERNAME/REPOSITORY-NAME.git
Important
It is important to use the HTTPS or Git protocol instead of a SCP-style SSH URL. Business Central does not support the basic SSH URL and fails with Invalid URL format.Figure 3.1. An invalid SCP-style SSH URL.
- User Name: your Git user name
- Password: your Git password
- Go to the created repository:
~]$
cd $JBOSS_HOME/bin/.niogit/REPOSITORY-NAME.git
- Change the remote URL:
~]$
git remote set-url origin git@github.com:USERNAME/REPOSITORY-NAME.git
Make sure that you can access the remote repository through command line using SSH. For example, the private SSH key for the repository should exist under the~/.ssh/
directory. - Verify that the remote repository was successfully added:
~]$
git remote -v
The command should list the following:origin git@github.com:USERNAME/REPOSITORY-NAME.git (fetch) origin git@github.com:USERNAME/REPOSITORY-NAME.git (push)
- Create a file named
post-commit
with the permissions set torwxr--r--
under$JBOSS_HOME/bin/.niogit/REPOSITORY-NAME.git/hooks
with the following content:#!/bin/sh git push origin master
- Make sure that the configuration was successful by creating a new guided rule in Business Central: go to Authoring → Project Authoring and then New Item → Guided Rule below. Fill in the required information in the displayed Create new Guided Rule window and click Ok.All of the changes should be pushed automatically.
For further information about remote Git repositories, refer to this article: How to configure the BxMS 6 server to use a remote Git repository for storing assets?
Furthermore, it is also possible to specify the system property
org.uberfire.nio.git.hooks
. Its value determines a directory with default hook files that will be copied to the newly created Git repositories. See the example of a standalone.xml
file with this setting below:
<system-properties> <property name="org.uberfire.nio.git.hooks" value="/opt/jboss-as/git-hooks"> </property> ... </system-properties>