Configuring the Git repository and hooks by using scripts

The IBM® Engineering Workflow Management (EWM) Git Integration Toolkit includes scripts that you can use to configure a Git repository and the hooks that the integration uses.

Prerequisites

You must have the following programs installed and included in the PATH environment variable.

  • bash
  • getopt
  • git
  • sed

You can use these scripts only on Git repositories that have not been configured.

Logging

Three of the scripts include a logging trace level parameter. Set the parameter to one of the following values.

Table 1. Logging trace levels
Trace level Description
0 No logging.
1 Errors
2 Warnings
3 Informational
4 Verbose

configure-git-repo-config.sh

Use this script to configure a Git repository. Run the script as the user who owns the Git repository directory. The script adds two fields to the config file: rtc.repourl and rtc.repokey. Before the script modifies the config file, it creates a backup version of the file.

Table 2. Parameters for configure-git-repo-config.sh
Parameter Description
g Git repository file path.
h Help.
r Repository URL.
k Git repository key.
Example:
$ cd EWM-Git-Integration-Toolkit/tools/install
$ ./configure-git-repo-config.sh \ 
	-g /opt/git-data/repos/myrepo.git \
	-r https://localhost:9443/ccm \
	-k cd5d0cde8e8e11e9bc42526af7764f64

configure-git-hooks-node.sh

Use this script to configure the pre-receive and post-receive scripts in the Git repository when integrating with a Node.js server. Run the script as the user who starts the Node.js server. That user should have permission to write to the config file of the Git repository. The script configures the pre-receive and post-receive scripts from the EWM-Git-Integration-Toolkit/server/hooks/examples directory and copies them to the hooks directory of the Git repository.

Table 3. Parameters for configure-git-hooks-node.sh
Parameter Description
g Git repository file path.
h Help.
l Logging trace level.
n Node.
t File path to Git toolkit.
Example:
$ cd EWM-Git-Integration-Toolkit/tools/install
$ ./configure-git-repo-config.sh \ 
	-t /opt/rtc-git-toolkit/ \
	-g /opt/git-data/repos/myrepo.git \
	-l 4 \ 
	-n /usr/bin/node

configure-gitlab-hooks.sh

Use this script to configure the pre-receive and post-receive scripts in the Git repository when integrating with a GitLab server. Run the script on the GitLab server computer as the user who logs in to gitlab-shell. The default user ID is git. Contact your administrator to get the user ID. The script configures the pre-receive and post-receive scripts from the EWM-Git-Integration-Toolkit/server/hooks/examples/gitlab directory and copies them to the custom_hooks directory of the Git repository.

Table 4. Parameters for configure-gitlab-hooks.sh
Parameter Description
h Help.
g Git repository file path.
k Git repository key.
l Logging trace level.
n Node.
r Repository URL.
s Skip SSL verification.
t File path to Git toolkit.
u Functional user: EWM user ID.
Example:
$ cd EWM-Git-Integration-Toolkit/tools/install
$ ./ configure-gitlab-hooks.sh \
	-t /opt/rtc-git-toolkit \
	-g /opt/git-data/repos/myrepo.git \
	-r https://localhost \
	-k cd5d0cde8e8e11e9bc42526af7764f64 \
	-l 2 \
	-u ccm_user \
	-n /usr/bin/node \
	-s 

configure-gerrit-hooks.sh

Use this script to configure the pre-receive and post-receive scripts in the Git repository when integrating with a Gerrit server. Run the script as the user who owns the Gerrit installation directory. The script configures the ref-update, ref-updated, and patchset-created scripts from the EWM-Git-Integration-Toolkit/server/hooks/examples/gerrit directory and copies them to the hooks directory in the Gerrit installation directory. If the hooks directory is not present the script creates it.

Note:

This script assumes the default configuration of the Gerrit server. For details about the default configuration, see the Configuration section at https://gerrit.googlesource.com/plugins/hooks/+/master/src/main/resources/Documentation/config.md.

Table 5. Parameters for configure-gerrit-hooks.sh
Parameter Description
g Git repository file path.
h Help.
l Logging trace level.
n Node.
t File path to Git toolkit.
Example:
$ cd EWM-Git-Integration-Toolkit/tools/install
$ ./configure-gerrit-hooks.sh \
	-t /opt/rtc-git-toolkit \
	-g /gerrit \
	-l 2 \
	-n /usr/bin/node 

video icon Video

Jazz.net channel
Software Education channel

learn icon Courses

IoT Academy
Skills Gateway

ask icon Community

Jazz.net
Jazz.net forums
Jazz.net library

support icon Support

IBM Support Community
Deployment wiki