🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › use ci/cd to build your application › tutorials › tutorial: your first pipeline
Tutorial: Create and run your first GitLab CI/CD pipeline | GitLab Docs
View a visual representation of your pipeline by selecting the pipeline ID (#2435445330 in this example): View details of a job by selecting the job name. For example, deploy-prod: You have successfully created your first CI/CD pipeline in GitLab.
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › use ci/cd to build your application › getting started
Get started with GitLab CI/CD | GitLab Docs
By default, the filename must be ... might be build, test, and deploy. Jobs specify the tasks to be performed in each stage. For example, a job can compile or test code....
Discussions

I built a brand new CI/CD for my team and here what I can recommend you
I'm doing the same exact migration you did for my company, from Bamboo to gitlab-ci. We decide to use cicd components because it gives the opportunity to test modifications before new version become available to be applied to pipelines. I have some questions about your explanation, about deploying. You write: 2. Deploy to Staging pipeline (runs automatically for a tag) 3. Deploy to Production pipeline (runs manually for same tag) It make perfectly sense, but in your example you show only 1 deploy pipeline and it seems that same pipeline contains both job to deploy in staging and in prod environment (none of them manual btw). Could you provide a pipeline example that it's more adherent to your explanation? More on reddit.com
🌐 r/gitlab
16
31
July 8, 2024
GitLab CI pipeline
You can use multiple files. For any given pipeline, there is one CI configuration file that is loaded initially, but that file can include: (even conditionally/dynamically) many other CI configuration files. They can even be included remotely, like in another project, or even a remote URL. For example, you may have multiple configurations for a monorepo kind of setup, separate CI files for different branches/tags, workflows, or whatever. See: Use CI/CD configuration from other files . In very advanced use cases, you can even generate child pipeline configurations on-the-fly. There's a lot of flexibility in GitLab CI! More on reddit.com
🌐 r/gitlab
9
7
July 31, 2024
Just created my first CI/CD pipeline. What should I learn next?
Learn the REST API. The glab api sub command will make things a little nicer than having to do everything with curl. Also, there’s an unofficial gitlab-ci-local project that covers most of the possible pipeline scenarios. That will make it a lot faster to develop pipelines than constantly pushing repos and clicking around to simulate various events. Also, look into the To Be Continuous project for a powerful suite of powerful and flexible CI components. More on reddit.com
🌐 r/gitlab
3
3
December 13, 2025
Need some help/general guidance with CI/CD pipeline
You could use predefined variables for 3. $GITLAB_USER_ID or $GITLAB_USER_LOGIN will resolve to the user that started the pipeline or, if in a manual job, the user that started the job. From there it's going to depend on how you want to define how the IP addresses are associated with the user id or login. Storing them as key value pairs in a JSON file in the repo and reading from it using something like jq would be my first option. Basically grab the ID using the GitLab variable and then lookup the corresponding ID in your "user-ips.json" file. More on reddit.com
🌐 r/gitlab
8
1
January 16, 2024
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › use ci/cd to build your application › pipelines
CI/CD pipelines | GitLab Docs
In the left sidebar, select Settings > CI/CD. Expand Pipeline subscriptions. Select Add project. Enter the project you want to subscribe to, in the format <namespace>/<project>. For example, if the project is https://gitlab.com/gitlab-org/gitlab, use gitlab-org/gitlab.
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › use ci/cd to build your application › tutorials › ci/cd examples
CI/CD examples | GitLab Docs
Examples and community-contributed guides for implementing GitLab CI/CD across languages, frameworks, and deployment targets.
🌐
GeeksforGeeks
geeksforgeeks.org › devops › how-to-write-ci-cd-pipeline-using-gitlab
How To Write CI/CD Pipeline Using GitLab? - GeeksforGeeks
July 23, 2025 - We'll create a CI/CD pipeline for a website, which will execute automatically whenever changes are merged in the main branch, and then the website will go through 3 stages - build, test, and deploy and will go through the defined rules. Step 1: Create your Gitlab account from https://about.gitlab.com/ We'll use the Website version, but you can also install Gitlab on your machine.
🌐
Velotio
velotio.com › engineering-blog › create-ci-cd-pipeline-in-gitlab-in-under-10-mins
Create CI/CD Pipeline in GitLab in under 10 mins
For example, if you want to run unit tests on branch A and perform functional testing on branch B, you can simply modify the YAML configuration for CI/CD, and the runner will take care of running the job for you.
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › use ci/cd to build your application › ci/cd yaml syntax reference
CI/CD YAML syntax reference | GitLab Docs
Some CI/CD variables are supported. ... include: - local: build_jobs.yml rules: - if: $INCLUDE_BUILDS == "true" test-job: stage: test script: echo "This is a test job" In this example, if the INCLUDE_BUILDS variable is: true, the build_jobs.yml configuration is included in the pipeline.
🌐
GitHub
github.com › dokku › gitlab-ci
GitHub - dokku/gitlab-ci: A collection of gitlab-ci examples · GitHub
All examples require a SSH_PRIVATE_KEY ... CI pipeline. This may be set via a "secret variable". See this doc for instructions on creating a new ssh key. Be careful not to overwrite existing keys on the generating machine by using a new name. Browse to the repository in question and visit the following path: the Gitlab project > Settings > CI/CD...
Author: dokku
Find elsewhere
🌐
Medium
medium.com › @almaswebconsulting › the-ultimate-guide-to-gitlab-ci-cd-along-with-example-of-building-ci-cd-pipeline-for-python-8d2ca26aff7f
The Ultimate Guide to GitLab CI/CD: Along with Example of Building CI/CD Pipeline for Python | almas | Medium
April 4, 2024 - These types include basic pipelines, multi-branch pipelines, merge request pipelines, parent-child pipelines, scheduled pipelines, multi-job pipelines, etc. Commit is a record of changes made in the code or files.
🌐
Codefresh
codefresh.io › home › devops › gitlab ci/cd › gitlab ci/cd tutorial
GitLab CI/CD Tutorial: From Basic To Advanced | Octopus Deploy
By automating the testing, building, and deployment stages, GitLab CI/CD improves productivity and reduces the risks associated with manual processes. In GitLab CI/CD, the automation begins with a file called .gitlab-ci.yml that defines the stages, jobs, and variables needed for the pipeline execution.
🌐
Medium
medium.com › @amit151993 › building-a-production-grade-gitlab-ci-cd-pipeline-31d040cb66b3
Building a Production-Grade GitLab CI/CD Pipeline | by Amit Singh | Medium
January 4, 2026 - CI_REGISTRY_* built-in variables for GitLab Container Registry. KUBE_CONFIG should be stored as a CI/CD variable (base64-encoded) in project settings. Below is a real, production-focused configuration that includes caching, parallel tests, review apps, protected deployments, and Kubernetes rollout: stages: - prepare - build - test - security - package - review - deploy variables: IMAGE_TAG: "$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID" DOCKER_DRIVER: overlay2 cache: key: "${CI_COMMIT_REF_SLUG}" paths: - node_modules/ - .m2/repository/ prepare: stage: prepare image: node:20 script: - npm ci artifacts: paths: [node_modules/] build: stage: build image: docker:24-dind services: [docker:dind] script: - docker build -t "$CI_REGISTRY_IMAGE:$IMAGE_TAG" .
🌐
Spacelift
spacelift.io › blog › gitlab-ci-yml
Writing .gitlab-ci.yml File with Examples [Tutorial]
September 15, 2025 - You can then reference these variables within other parts of your CI/CD configuration, such as in your script commands — we saw this in action in the example above: variables: APP_NAME: "demo" test_job: stage: test script: - echo "Testing $APP_NAME" Variables can also be defined within the GitLab interface at the project, group, and instance level. GitLab provides many predefined variables too, such as $CI_COMMIT_SHA to get the SHA of the commit the pipeline’s running for, or $CI_COMMIT_BRANCH to discover the branch name.
🌐
YouTube
youtube.com › watch
GitLab CI CD Tutorial for Beginners [Crash Course] - YouTube
Learn GitLab CI/CD by building a complete CICD pipeline for a python demo project | with Docker🧡 GitLab Course with Kubernetes, Microservices, Multi-Stage:...
Published: June 9, 2022
🌐
Udemy
udemy.com › development
GitLab CI/CD: Pipelines, CI/CD and DevOps for Beginners
3 weeks ago - Explore yaml anchors and aliases to reduce duplication in GitLab CI/CD pipelines, using anchors, aliases, and merge keys to create reusable templates and common blocks like dependencies and before_script. Job templates with YAML anchors and aliases (practical example)10:40
Rating: 4.7 ​ - ​ 25.5K votes
🌐
YouTube
youtube.com › watch
GitLab CI/CD Pipeline Tutorial for Beginners - YouTube
🎯 New to GitLab? No worries! Start your DevOps journey with me:https://www.udemy.com/course/gitlab-ci-pipelines-ci-cd-and-devops-for-beginners/?couponCode=E...
Published: August 14, 2024
🌐
Medium
medium.com › @terminalsandcoffee › gitlab-ci-cd-pipeline-tutorial-9c074b0126aa
GitLab CI CD Pipeline Tutorial. If you want to follow along, you can… | by Terminals & Coffee | Medium
April 17, 2022 - A job doesn’t have to be associated with a stage, it can execute as a stand-alone job, however we do need to use the script keyword, which allows use to specify commands that the GitLab Runner assigned should execute. They execute in order. We begin to edit the code around minute 11 if you want to skip ahead the explanation he provides. We begin to remove the “sleep” statements, then we want to modify the build job to produce an executable binary file. Under the script keyword in the build job, we’re going to add another command. ... This will be our first commit, and as soon as we click commit changes, the pipeline will begin running.
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › use ci/cd to build your application › tutorials › tutorial: a complex pipeline
Tutorial: Create a complex pipeline | GitLab Docs
You can configure jobs to run in merge request pipelines, scheduled pipelines, or other specific situations. Rules are evaluated from top to bottom, and if a rule matches, the job is added to the pipeline. CI/CD variables: use these environment variables to configure job behavior in the configuration file and in script commands.
🌐
Reddit
reddit.com › r/gitlab › i built a brand new ci/cd for my team and here what i can recommend you
r/gitlab on Reddit: I built a brand new CI/CD for my team and here what I can recommend you
July 8, 2024 -

Background:

Two months ago I started to work on migration from Bamboo CI/CD to Gitlab.com for my team in a big enterprise company. Our project has microservices architecture, which are running as docker containers (around 80 containers) on our servers.

Our plan was to have our repositories in Gitlab and use Gitlab CI/CD pipelines to build and deploy our apps. We will use self hosted Gitlab Runners as shell executors. (no k8s is used)

I am very happy with the result we could achieve and that's why I want to share our best practices with you 💪.

Here are main concepts of our CI/CD process in Gitlab:

Shared Pipeline Templates:

As you probably guessed, having some many microservices means their build and deploy pipelines are almost identical. So we had to find a way to reuse some .yml templates. For this we created a new project in gitlab called ci-cd-assets. This project contains default pipeline for all our apps and reusable parts of pipeline like common jobs as well.

We tried to achieve individual .gitlab-ci.yml file as minimal as possible in every project to keep all pipeline code in central place. In case you want to change how pipelines work you simply change it in ci-cd-assetsproject and its applied everywhere.

Here is an example of .gitlab-ci.yml file:

variables:  
  APP_NAME: account-service

include:
  - project: $CI_PROJECT_NAMESPACE/ci-cd-assets
    file: /templates/app-pipeline.yml
    ref: master

☝️ For this you need to whitelist all other projects in settings of ci-cd-assets

Even though Gitlab now has a feature called CI/CD components and Catalogs, I didnt see any benefit of this approach and simply having shared repo felt like a better idea.

Shared Dockerfile and shell scripts:

Beside sharing .yml templates we also have default Dockerfiles and other scripts used inside pipelines.

As you probably guess all of them also sit in shared project ci-cd-assets. As a first step in every piepeline we checkout this shared repo files and save them as artifacts. By saving them as artifacts you can share this files with all consequent jobs inside pipeline. Here is an example:

get-shared-assets:
  variables:
    CI_CD_ASSETS_REPOSITORY_URL: https://gitlab-ci-token:$CI_JOB_TOKEN@gitlab.com/$CI_PROJECT_NAMESPACE/ci-cd-assets.git

  before_script:
    - echo "Checking out CI/CD assets..."
  script:
    - git clone $CI_CD_ASSETS_REPOSITORY_URL ./build
  artifacts:
    paths:
      - ./build/*

☝️ All files of shared project will be available during builds under ./build folder.

Versioning with Git Tags:

We develop using feature branches. New code is pushed to feature branch, after merge request is approved its merged in master and then latter deployed to staging and production environments. Deployment to staging happens automatically but manually to production after testing.

We decided to separate build pipelines and deploy pipelines by presence of a git tag. This means when commit is pushed or merged to master branch without a tag a build pipeline will start.

During this build pipeline we run unit tests, linting, building a docker image and publishing a docker image to container registry. This docker image has a tag which is an application version e.g v10.0.0. As a last step of build pipeline we create a git tag with the same version as docker image. Now we have git tag v10.0.0

This relationship tells us which commit produced which docker image and if this code is deployed to an environment this application version is actually used.

You can think that every git tag created in repo is a potential release. Then the same git tag (or version) of the application can be released to staging or production.

Build Pipeline:

Push to a branch (feature or default) will trigger a build pipeline. Green status of build pipeline tells us that build was successful and a new tag is created for a release.

This is a basic example of build pipeline yml:

stages:
  - prepare
  - build
  - post-build

include:
  - '/templates/get-ci-cd-assets.yml'

build-and-test:
  stage: build
  before_script:
    - echo "Start building and testing..."
  script:
    - ./build/scripts/docker-build.sh
    - ./build/scripts/docker-push.sh 

tagging:
  stage: post-build
  before_script:
    - echo "Tagging the release with version..."
  script:
    - ./build/scripts/create-tag.sh

Deploy Pipeline:

Git tag creation will trigger a deploy pipeline. In Gitlab tag creation is one of the pipeline triggers. Deploy pipeline will read a tag for what it is currently running (which indicates a docker image version) and use this version inside a deploy script.

By this approach we could separate build and deploy pipelines. 😊 This means a commit to master branch (or merge) will first trigger a build pipeline, when build finishes a tag is created with a version. This tag will trigger a deploy pipeline to release this version so some environment.

This is an example of app pipeline yml file:

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE != "merge_request_event"  # do not run MR creation
  
include:
  - local: '/templates/build-pipeline.yml'
    rules:
      - if: $CI_COMMIT_TAG == null
  - local: '/templates/deploy-pipeline.yml'
    rules:
      - if: $CI_COMMIT_TAG

☝️ Simply includes different pipeline templates based on git tag presence.

Lets say we merged a MR to master and deployed it to staging and production. This process produce 3 pipelines:

  1. Build pipeline (runs for a branch)

  2. Deploy to Staging pipeline (runs automatically for a tag)

  3. Deploy to Production pipeline (runs manually for same tag)

Another useful feature of Gitlab is Environments. When you attach an environment keyword to a job it becomes a deploy job and gives you an deployment history in Gitlab.

This is a basic example of deploy pipeline yml:

variables:
 ENVIRONMENT: 'staging'

deploy-staging:
  stage: deploy
  variables:
    VERSION: $CI_COMMIT_TAG # read version from tag
  environment: staging
  before_script:
    - echo "Deploying to staging..."
  script:
    - ./build/scripts/deploy.sh $APP_NAME $VERSION $ENVIRONEMNT
  rules:
    - if: $ENVIRONMENT == 'staging'
      
deploy-production:
  stage: deploy
  variables:
    VERSION: $CI_COMMIT_TAG # read version from tag
  environment: production
  before_script:
    - echo "Deploying to production..."
  script:
    - ./build/scripts/deploy.sh $APP_NAME $VERSION $ENVIRONEMNT
  rules:
    - if: $ENVIRONMENT == 'production'

☝️ Default value of $ENVIRONMENT is 'staging', so deploy to staging happens automatically. To deploy a tag to production, you can manually start a pipeline, select a desired tag and set overwrite variable ENVIRONMENT to 'production'.

Any opinions are welcomed! Enjoy! 🎉

🌐
DEV Community
dev.to › arbythecoder › how-to-set-up-a-cicd-pipeline-with-gitlab-a-beginners-guide-46b9
How to Set Up a CI/CD Pipeline with GitLab: A Beginner's Guide - DEV Community
June 11, 2024 - Trigger the Pipeline: The pipeline will automatically trigger when you push the .gitlab-ci.yml file. ... Go to your GitLab project page. Navigate to CI/CD > Pipelines.