This guide will walk through for enabling CI/CD Process in GitLab. GitLab CI/CD had many features like multi-language builds, Parallel builds, versioned tests, pipelines, auto-scaling, build artifacts, testing, Docker.
Following are the steps to configure CI/CD process in GitLab for Maven Build.
- JDK 1.8 +
- Maven 3.5.0 +
- GitLab Runner
Note: All these installations have done in RedHat 7.5 in the single server.
- Install Java 8 and Maven in GitLab server.
- To install GitLab Runner in GitLab Server for RedHat 7.5 run the following commands
# curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
# sudo yum install gitlab-runner
- GitLab runner will create user with /home/gitlab-runner. All the builds will be in this directory.
- Next, need to configure runner for the project there are three runners
Shared Runner: These are used for Multiple Projects with Similar requirements.
Specific Runner: These are for Individual Jobs.
Group Runner: These are for multiple projects which is under one group.
In our case, we will use Specific Runner for these
- Go to Project > Settings> CI/CD Settings > Runner Settings . Copy the Token as shown in the screenshot.
- Next login to the GIT Server from Putty and run following commands
# gitlab-runner register
Need to give following information to register the runner
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/): <Enter GitLab Server URL>
Please enter the gitlab-ci token for this runner: <Enter the token from above step>
Please enter the gitlab-ci description for this runner: < Description of the runner >
Please enter the gitlab-ci tags for this runner (comma separated): <Give tag for the runner>
Whether to lock the Runner to the current project [true/false]: true
Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, VirtualBox, docker-ssh, shell: shell
- After updating the details go to Project > CI/CD > Jobs this will show you the CI Jobs.
- Create .gitlab-ci.yml in Project Root directory with the following content and commit.
– mvn clean install
Whenever any developer commits the build Build will be triggered automatically.