GITLAB CI/CD PIPELINE

Shrutiunadkat
4 min readMar 21, 2023

--

GitLab CI/CD is a part of GitLab used for implementing various “continuous” methods, such as Continuous Integration (CI), Continuous Delivery (CD), and Continuous Deployment. GitLab CI/CD allows you to build, test, and publish software without needing a third-party integration or application.

Features

  1. It is integrated in GitLab interface.
  2. It has earned more popularity in the past few years due to its simple usage, faster results etc.
  3. It allows the project team members to integrate their work daily.
  4. The integration errors can be identified easily by an automated build.
  5. It can be executed on multiple platforms such as Windows, Unix, OSX and other platforms which support Go programming language.

Advantages

  1. It is easy to learn, use and scalable.
  2. It displays the faster results as it divides the each build into multiple jobs that run on multiple machines.
  3. It is free and open source software which is added in both GitLab Community Edition and the proprietary GitLab Enterprise Edition.

Usage of Gitlab CI/CD −

  1. It is easy to learn, use and scalable.
  2. It is faster system which can be used for code deployment and
    development.
  3. You can execute the jobs faster by setting up your own runner (it is an
    application that processes the builds) with all dependencies which are
    pre-installed.
  4. GitLab CI solutions are economical and secure which are very flexible in costs as much as machine used to run it.
  5. It allows the project team members to integrate their work daily, so that
    the integration errors can be identified easily by an automated build.

Create CI/CD Pipeline :

Step 1. Create a GitLab project

  1. Go to the top bar and click on Main menu. Go to Projects and select View all projects.
  2. Click on New project on the page’s right.
  3. Select one of the following options on the Create new project page:

     Blank project
     Built-in template
     Custom template
     Import a project from another repository
     HIPAA audit template.
     Connect to an external repository

Step 2: Ensure you Have Available Runners

To enable actions on GitLab CI/CD, you must make sure there are available
runners to run the GitLab CI/CD jobs. A GitLab runner is an agent that runs
CI/CD jobs.
If you use GitLab.com, you can skip to the next step because GitLab SaaS will provide the runners.
1. View the available runners by going to CI/CD under Settings and
expanding the Runners option. If you have one or more active runners
(i.e., with green circles next to them), there will be a runner to process the
CI/CD jobs.
2. You may have an available runner, including a shared runner available to
all projects in the GitLab instance. If this is the case, skip the next step.
3. If there are no runners, you can install a GitLab Runner and register the
runner for your group, instance, or project.

Step 3: Create a Job Definition File

Create a new .gitlab-ci.yml file at the repository’s root. This file will hold the definitions for your jobs. Define the following in the configuration file:

  1. The jobs the runner must execute and their order.
  2. The decisions the runner must make when encountering specific
    conditions. For example, you could run a test suite when committing to a branch other than the default branch (committing to the default
    branch should involve running the same test suite and publishing
    the application).

To Create the .gitlab-ci.yml file:

1. Go to Project information on the sidebar to the left and select Details.
2. Select the desired branch above the file list, click on the plus icon, and
select New file.

3. Enter .gitlab-ci.yml for the Filename and paste the relevant code in the large window.
For example:

$CI_COMMIT_BRANCH and $GITLAB_USER_LOGIN are defined variables that GitLab will populate when it runs the job.

4. Finally, click Commit changes.

Commit TO START THE pipeline

Step 4: View Status of Jobs and Pipelines

The pipeline should start after you commit the changes.

To view the pipeline:

  1. Go to CI/CD and select Pipelines.

It should display your pipeline, including three stages.

2. Select your pipeline’s ID to view its visual representation.

3. To view a job’s details, select the desired job’s name — e.g., deploy-prod.

REFERENCE :

https://docs.gitlab.com/ee/ci/

Prepared By :

20CE045 Yashvi Kotadiya

20CE138 Hetvi Soni

20CE142 Khushi Tala

20CE153 Shruti Unadkat

20CE156 Dhruvi Vaishnav

--

--