Chapter 12. Repository hooks

In Decision Central, you can use scripts, known as hooks, to configure the repository to trigger a specified action every time a particular event happens.

12.1. Configuring git hooks

Decision Central can automatically push changes to a remote repository using Git hooks. After you configure the post-commit hook, Decision Central automatically pushes your changes to the remote repository.

Note

Currently only post-commit hooks are supported. Post-commit hooks are triggered after the commit process finishes.

Prerequisites

  • Red Hat Decision Manager projects exist in an external Git repository.
  • Credentials required for read access to that external Git repository are available.

Procedure

  1. Log in to Decision Central.
  2. Go to MenuProjects.
  3. Select or create the space into which you want to import the projects.
  4. Click dots on the right side of the screen and select Import Project.
  5. In the Import Project window, enter the URL (for example, https://github.com/USERNAME/REPOSITORY_NAME.git) and credentials for the Git repository that contains the project that you want to import and click Import.

    The project is added to the Decision Central Git repository and is available in the created or default space.

    Important

    Use the HTTPS or Git protocol instead of a SCP-style SSH URL. Decision Central does not support the basic SSH URL and an error appears if you use this URL.

  6. In a terminal window, change to the created repository.

    cd JBOSS_HOME/bin/.niogit/REPOSITORY_NAME.git
  7. Create the post-commit file in the JBOSS_HOME/bin/.niogit/REPOSITORY_NAME.git/hooks directory, set the permissions to rwxr—​r-- and add the following content:

    #!/bin/sh
    git push origin master
  8. Make sure that the configuration was successful by creating a new guided rule in Decision Central:

    1. Go to MenuProjectsAdd AssetGuided Rule.
    2. Fill in the required information in the displayed Create new Guided Rule window.
    3. Click Ok.

      Decision Central automatically pushes all changes to the remote repository.

You can also specify the org.uberfire.nio.git.hooks system property. Specify a directory with default hook files as the value for this property. This directory will be copied to the newly created Git repositories. See the following 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>
Additional resources