此内容没有您所选择的语言版本。
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.
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
ImportantIt 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
Change to the created repository:
cd JBOSS_HOME/bin/.niogit/REPOSITORY_NAME.git
cd JBOSS_HOME/bin/.niogit/REPOSITORY_NAME.git
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change the remote URL:
git remote set-url origin git@github.com:USERNAME/REPOSITORY_NAME.git
git remote set-url origin git@github.com:USERNAME/REPOSITORY_NAME.git
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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.If you created a new repository, you may encounter the following error:
fatal: No such remote 'origin'
fatal: No such remote 'origin'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To resolve it, add the remote origin URL:
git remote add origin git@github.com:USERNAME/REPOSITORY_NAME.git
git remote add origin git@github.com:USERNAME/REPOSITORY_NAME.git
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the remote repository was successfully added:
git remote -v
git remote -v
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The command should list the following:
origin git@github.com:USERNAME/REPOSITORY_NAME.git (fetch) origin git@github.com:USERNAME/REPOSITORY_NAME.git (push)
origin git@github.com:USERNAME/REPOSITORY_NAME.git (fetch) origin git@github.com:USERNAME/REPOSITORY_NAME.git (push)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a file named
post-commit
with the permissions set torwxr--r--
underJBOSS_HOME/bin/.niogit/REPOSITORY_NAME.git/hooks
with the following content:#!/bin/sh git push origin master
#!/bin/sh git push origin master
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make sure that the configuration was successful by creating a new guided rule in Business Central:
-
Go to Authoring
Project Authoring New Item Guided Rule. - Fill in the required information in the displayed Create new Guided Rule window.
- Click Ok.
-
Go to Authoring
All of the changes should be pushed automatically.
For further information about remote Git repositories, see How to configure the BxMS 6 server to use a remote Git repository for storing assets?.
It is also possible to specify the system property org.uberfire.nio.git.hooks
. Its value determines a directory with default hook files, which 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>
<system-properties>
<property name="org.uberfire.nio.git.hooks" value="/opt/jboss-as/git-hooks">
</property>
...
</system-properties>