Gitlab CI/CD Basics
GitLab CI/CD allows you to automate workflows directly from your GitLab repository. It enables you to build, test, and deploy your code based on specific events (such as code pushes, merge requests)
Key Concepts of GitLab CI/CD
Pipelines: Automated processes that you define in your repository.
Stages: Groups of jobs that run sequentially (e.g., build, test, deploy).
Jobs: Tasks that run in parallel within a stage.
Scripts: Commands that run in the job's environment.
Runners: Servers that execute the jobs in your pipeline.
Adding a GitLab CI/CD Pipeline to Your Repository
Create a .gitlab-ci.yml
File:
.gitlab-ci.yml
File:Create a
.gitlab-ci.yml
file in the root directory of your repository.Use YAML syntax to define your pipeline.
Breakdown:
stages
: The stages that will run as part of the pipeline.variables
: Environment variables for your pipeline.llm-experiment-job
: The name of the job that will run.stage
: Specifies which stage the job belongs to.image
: The Docker image to use for the job.only
: Conditions that determine when the job will run.script
: Commands to run in the job.artifacts
: Files to save after the job completes.
Common only
Event Options:
only
Event Options:Merge Requests: Triggers the pipeline when a merge request is created or updated.
Specific Branches: Triggers the pipeline when code is pushed to specific branches.
Changes to Specific Files: Triggers the pipeline when specific files are changed.
Scheduled Pipelines: Triggers the pipeline on a scheduled time.
Tags: Triggers the pipeline when a tag is created.
Combining Multiple Conditions: You can combine multiple conditions for more granular control.
Last updated
Was this helpful?