19.5. Integrating remote Git repositories


In the following example, you use a post-commit Git hook and Java code to integrate Business Central with a remote Git repository. For the Java code example, see Business Central post-commit Git Hooks Integration. The example provides the following functionality:

  • Automatic generation of the template .gitremote configuration file
  • Validation of the .gitremote configuration file for required parameters
  • Patterns defined in the ignore parameter of the .gitremote file are ignored by Git
  • Message and notification output to users
  • Support for GitLab and GitHub token authentication
  • Support for GitLab group and subgroup project creation
  • Support for GitHub organization repository creation

Prerequisites

  • Red Hat Decision Manager is installed in a Red Hat JBoss EAP 7.2 server instance.
  • Java Development Kit (JDK) 8 is installed.
  • Maven is installed.

Procedure

  1. In a terminal window, clone the GitHub repository to your system:

    $ git clone https://github.com/kiegroup/bc-git-integration-push.git
    Copy to Clipboard Toggle word wrap
  2. Navigate to the cloned repository:

    $ cd bc-git-integration-push
    Copy to Clipboard Toggle word wrap
  3. Execute a Maven clean install:

    $ mvn clean install
    Copy to Clipboard Toggle word wrap
  4. Create a /hooks folder in your EAP_HOME directory:

    $ mkdir -p _EAP_HOME_/hooks/
    Copy to Clipboard Toggle word wrap
  5. Copy the git-push-2.1-SNAPSHOT.jar to the EAP_HOME/hooks/ folder:

    $ cp bc-git-integration-push/target/git-push-2.1-SNAPSHOT.jar _EAP_HOME_/hooks/
    Copy to Clipboard Toggle word wrap
  6. Optional: To create a template .gitremote configuration file, run git-push-2.1-SNAPSHOT.jar:

    $ java -jar git-push-2.1-SNAPSHOT.jar
    Copy to Clipboard Toggle word wrap

    Example template .gitremote configuration file

    #This is an auto generated template empty property file
    provider=GIT_HUB
    login=
    password=
    token=
    remoteGitUrl=https://api.github.com/
    useSSH=false
    ignore=.*demo.*, test.*
    githubOrg=OrgName
    gitlabGroup=Group/subgroup
    Copy to Clipboard Toggle word wrap

  7. Modify the .gitremote configuration file parameters.

    Expand
    表19.1 Example .gitremote parameters
    ParameterDescription

    provider

    The Git provider. Only two values are accepted: GIT_HUB and GIT_LAB. Required

    login

    The username for the Git provider. Required

    password

    A plain text password. Not required if a token is provided.

    token

    A generated token to replace the username and password based unsecured connection. Note: If this is not set a warning is displayed that you are using an unsecured connection. Not required if a password is provided. Note: GitLab only supports token authentication.

    remoteGitUrl

    A public provider URL or a locally hosted enterprise for any provider. Required. Note: The public GitHub URL should be the API URL. For example, api.github.com.

    useSSH

    Boolean to allow the SSH protocol to push changes to the remote repository. Optional. Default = false. Note: This parameter uses the local ~/.ssh/ directory to obtain the SSH configuration.

    ignore

    A comma separated regular expressions to ignore project names that match any of these expressions. Optional.

    githubOrg

    Defines the repository organization if GitHub is used as the provider. Optional.

    gitlabGroup

    Defines the repository group and subgroup if GitLab is used as the provider Optional.

  8. Create a post-commit Git hook file in EAP_HOME/hooks:

    $ touch post-commit
    Copy to Clipboard Toggle word wrap
  9. Set the permissions of the post-commit file to 755:

    $ chmod 755 post-commit
    Copy to Clipboard Toggle word wrap
  10. Add #!/bin/bash and code to execute git-push-2.1-SNAPSHOT.jar to the post-commit file:

    $ echo "#\!/bin/bash\njava -jar $APP_SERVER_HOME/hooks/git-push-2.1-SNAPSHOT.jar" > hooks/post-commit
    Copy to Clipboard Toggle word wrap
  11. Start Business Central with the -Dorg.uberfire.nio.git.hooks environment variable set. For example:

    $ ./standalone.sh -c standalone-full.xml -Dorg.uberfire.nio.git.hooks=_EAP_HOME_/hooks
    Copy to Clipboard Toggle word wrap
注記

To use post-commit Git hooks that execute Java code, you must use the following Java libraries:

  • JGit: Used to interact with internal Business Central Git repositories.
  • GitHub API for Java: Used to communicate with GitHub.

For more information about post-commit Git hook and Java code examples, see Business Central post-commit Git Hooks Integration.

トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat