Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

GitLab guide

Access
Operations
Cloning
Git flow
Branching
Tagging
Build
Maven
Create Deploy-Token
Configure settings.xml
Configure packages location on pom.xml
Deploy

Access
Connect Helix HQ VPN

Setup hosts file to map IP and domain.

1 # gitlab

2 10.5.0.22 git.helix-int.com

GitLab URL: http://10.5.0.22 or http://git.helix-int.com (with hosts file mapping)

Operations
Cloning
Go to repository and select Clone to get code, either via SSH or HTTP
To clone with SSH, need to setup setup SSH Keys by:
Create a public key/private key pair and store under ~/.ssh, name it like id_rsa and id_rsa.pub .
Go to http://git.helix-int.com/-/profile/keys and copy public key content in id_rsa.pub into Key box and Add key .

Go to ~/.ssh and create file config if not exists and add following content:

1 Host git.helix-int.com

2 HostName git.helix-int.com

3 User git

4 Port 220

5 IdentityFile "C:\Users\{username}\.ssh\id_rsa"

Open command line tool and type use git clone command, for example git clone git@git.helix-
int.com:common/HelixUtil.git

Or to clone with HTTP, just enter username & password when required.
Or clone in IDE like VS Code, VS, IntelliJ, Eclipse…
While cloning for the first time, it will ask to allow adding fingerprint, just type yes .
Git flow
Branching

There are some types of branch:

master :

The main branch for production.


Developers are not allowed to push directly into master branch.
develop :

The main branch for development.


After testing is ok, this branch will be merged into master .
feature :

Each developer when working on a task need to create a separate feature branch for that.
Feature branch should be named like: feature/TASK-ID_task_description

After complete, developer will create a Merge Request to merge this feature branch into develop branch.
The Merge Request will be reviewed by other Developers or by Leader.
Other types of branch like bugfix will be same as feature branch except for the prefix.
hotfix :

Branch from a release tag on master and merged to master for release the next hot fix, usually with a minor version upgrade.
The changes from hotfix then merged back to develop to sync the code. Either by merging the hotfix branch or master branch.

Tagging

After the code in master is ok, create a Tag with version, like 9.0.1. Then build the library/executable from this point.

Build
Maven
Create Deploy-Token

Go to Group’s Settings->Repository->Deploy tokens.


Create a token by fill in Name, Expiration, Username and check all permissions, then click Generate deploy token

Copy token value and save for later usage.

Configure settings.xml

Create settings.xml with below content and place in ~/.m2

1 <?xml version="1.0" encoding="UTF-8"?>

3 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"

4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

5 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.
6 <localRepository>${user.home}/.m2/repository</localRepository>

8 <servers>

9 <server>

10 <id>gitlab-packages</id>

11 <configuration>

12 <httpHeaders>

13 <property>

14 <name>Deploy-Token</name>

15 <value>{group_deploy_token}</value>

16 </property>

17 </httpHeaders>

18 </configuration>

19 </server>

20 </servers>

21 </settings>

Configure packages location on pom.xml

1 <repositories>

2 <repository>

3 <id>gitlab-packages</id>

4 <url>http://git.helix-int.com/api/v4/groups/{group_id}/packages/maven</url>

5 </repository>

6 </repositories>

8 <distributionManagement>

9 <repository>

10 <id>gitlab-packages</id>

11 <url>http://git.helix-int.com/api/v4/projects/{project_id}/packages/maven</url>

12 </repository>

13 <snapshotRepository>

14 <id>gitlab-packages</id>

15 <url>http://git.helix-int.com/api/v4/projects/{project_id}/packages/maven</url>

16 </snapshotRepository>

17 </distributionManagement>

Deploy

Run mvn deploy to publish build & publish output to packages.

The output in GitLab Packages looks like:

You might also like