Gitlab Ci/Cd: An Overview
Gitlab Ci/Cd: An Overview
Gitlab Ci/Cd: An Overview
Created By:
Sheik Benazir Ahmed
GitLab CI/CD
(All contents are taken
from Gitlab’s official
documentation.)
Continuous Integration/Delivery/Deployment
Continuous Integration
• You can create a set of scripts to build and test your application automatically, for every push to the repository.
• This practice is known as Continuous Integration.
• These scripts help decrease the chances that you introduce errors in your application.
Continuous Delivery
• Step beyond Continuous Integration.
• Each time a code change is pushed to the codebase, the application is also deployed continuously.
• It requires human intervention to manually and strategically trigger the deployment of the changes.
Continuous Deployment
• Same as continuous delivery with one difference:
• Instead of deploying your application manually, you set it to be deployed automatically.
• Human intervention is not required
• Contents:
Get Started: • CI/CD process overview
• Creating a sample “.gitlab-ci.yml” file
• View the status of your pipeline and jobs
• CI/CD Concepts
• Enable or Disable CI/CD
• To use GitLab CI/CD:
• Ensure you have runners available to run your
jobs.
• If you don’t have a runner:
• Install GitLab Runner and register a
Get Started: CI/CD runner for your instance, project, or
group.
process overview • Create a “.gitlab-ci.yml” file at the root of your
repository.
• This file is where you define your CI/CD
jobs.
Get Started: Creating a sample “.gitlab-ci.yml” file
Pipelines: Add • Just click the play button in the pipeline graph to execute
a particular job.
manual interactions • In the example below, the production stage has a job
with a manual action.
• Contents:
Jobs • Jobs
• Group jobs in a pipeline
• Specifying variables in manual job & Delay
a job
• Pipeline configuration begins with jobs.
• Jobs are:
• Defined with constraints stating
under what conditions they should
Jobs: Jobs be executed.
• Top-level elements with an
arbitrary name and must contain at
least the “script” clause.
• Not limited in how many can be
defined.
Jobs: Group jobs in
a pipeline
• To create a group of jobs, in the CI/CD
pipeline configuration file, separate each
job name with a number and one of the
following:
• A slash (/), for example, test 1/3, test
2/3, test 3/3.
• A colon (:), for example, test 1:3, test
2:3, test 3:3.
• A space, for example test 0 3, test 1 3,
test 2 3.
• The example on the top right shows three
jobs that are in a group named build ruby
.
Jobs: Specifying variables in manual job & Delay a job
• Supply additional job specific variables from the job page of the manual job to run.
• To access this page, click on the name of the manual job in the pipeline view.
• Use the “when:delayed” keyword to delay a job’s execution for a certain period.
• Contents:
Variables • CI/CD variables
• Predefined CI/CD variables
• Custom CI/CD Variables
• Create custom variables in the .gitlab-
ci.yml file
• CI/CD variable types
• Pass env var to another job
• Override a defined CI/CD variable
Variables: CI/CD variables
*** You do not have to use the same prefix or only slashes (/) in the
dynamic environment name. However, when you use this format, you
can group similar environments.***
Deployment tier of
environments
• By default, GitLab assumes a tier based on the
environment name.
• But you can still use an environment name like
customer-portal instead of production.
• But the name no longer indicates that the
environment is used for production.
• To indicate that a specific environment is for a
specific use, you can use tiers.
• You can use the deployment_tier keyword to specify
a tier.
Configure manual deployments