How to configure git hooks in B*MS 6.2+ / PAM 7.x / RHDM 7.x ?

Solution Unverified - Updated

Environment

  • Red Hat JBoss BRMS
    • 6.2.x
    • 6.3.x
    • 6.4.x
  • Red Hat JBoss BPM Suite
    • 6.2.x
    • 6.3.x
    • 6.4.x
  • Red Hat Process Automation Manager
    • 7.x
  • Red Hat Decision Manager
    • 7.x

Issue

  • Can business-central automatically push changes to its remote repository?
  • How to configure git hooks in BRMS 6.2?

Resolution

Git hooks support has been introduced since B*MS 6.2.0.GA. Please note that currently only "post-commit" hook is supported.

You can simply put your hook script, accordingly to the version used, under:

  • 6.x

     $JBOSS_HOME/bin/.niogit/<repo-name\>.git/hooks directory.
    
  • 7.x

    $JBOSS_HOME/bin/.niogit/<space>/<repo-name>.git/hooks directory
    

The following procedure is an example of "push when post-commit".

  1. [Authoring]->[Administration]
  2. [Repositories]->[Clone repository]
  3. Provide information then click OK
Repository Name: <as you like>
Organization Unit: <as you like>
Git URL: <your-https-url> for example, https://github.com/<username>/<repo-name>.git
User Name: <your-git-username>
Password: <your-git-password>

Using ssh in business-central [Clone repository] has some problems (business-central doesn't support SCP style ssh URL. https://bugzilla.redhat.com/show_bug.cgi?id=1299619 also passphrase would cause some problem when you use a basic ssh URL). So use https or git protocol here.
4) Go to the created repository

$ cd $JBOSS_HOME/bin/.niogit/<repo-name>.git
  1. Change the remote URL
$ git remote set-url origin git@github.com:<username>/<repo-name>.git

Make sure that you can access the remote repository via ssh in the command line. (e.g. the private ssh key for this remote repo exists under ~/.ssh)

  1. Confirm if the remote URL was set correctly
$ git remote -v
origin	git@github.com:<username>/<repo-name>.git (fetch)
origin	git@github.com:<username>/<repo-name>.git (push)
  1. Create a file named "post-commit" with executable permission (rwxr--r--) under $JBOSS_HOME/bin/.niogit/<repo-name>.git/hooks with the following content.
#!/bin/sh
git push origin master
  1. Confirm that 'push' is issued when you create a new "Guided Rule" via business-central.

For more information about working with remote git repositories, please refer to this article https://access.redhat.com/solutions/1281493

B*MS 6.2.0.GA has one more feature for git hooks.

You can specify system property "org.uberfire.nio.git.hooks". Its value is a directory which contains default hook files, which will be copied to newly created git repositories. Note that they are not copied to cloned repositories.

standalone.xml example:

    <system-properties>
         <property name="org.uberfire.nio.git.hooks" value="/opt/jboss-as/git-hooks"></property>
         ...

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.