How to trigger a Gitlab Pipeline on Merge? | Trigger Pipeline Using Rules | GitLab Tutorial

Sdílet
Vložit
  • čas přidán 12. 06. 2024
  • We're going to talk about, how to trigger a GitLab pipeline when we merge our code in two ways.
    Gitlab Merge triggers pipeline jobs. Pipeline rules is used by Merge.
    There are three main ideas we'll cover today.
    1. Use GitLab built-in Value Trigger Pipeline:
    The built-in value is CI_PIPELINE_SOURCE. and how to make it work differently.
    2. Benefit Merged Trigger Build:
    We'll discuss the advantages of triggering a pipeline upon merging.
    This is like having a safety net for our code changes.
    It ensures that our code doesn'tbreakn what's already working.
    3. Hands-on Demos:
    I'll walk you through the steps using CI_PIPELINE_SOURCE in job rule and workflow role, so you can see exactly how this works in action.
    👉🏼 Video content MD file: gitlab.com/lian.duan.training...
    👉🏼 Pipeline files: gitlab.com/lian.duan.training...
    ------------------------------------------------------------------------------------
    🧡 Subscribe to show your support! bit.ly/3hrhOmW
    ------------------------------------------------------------------------------------
    ⏰ T I M E S T A M P S ⏰
    00:00 🏁 Start
    01:02 🚩Use GitLab Built-in Value Trigger Pipeline
    02:45 🎖️Benefit Merged Trigger Build
    02:59 👋Hands-on Demos-Prerequisites
    03:33 👋Hands-on Demos-Add Merge Rule into Jobs
    05:18 👋Hands-on Demos-Add Merge Rule into Workflow
    07:06 📝 Summary
    ------------------------------------------------------------------------------------
    👉🏼Quick Share CI/CD Tips:
    • Quick Share CI/CD Tips
    Also, if you're new to Docker, Helm 3, or K8S, check out my guides below:
    👉🏼Helm 3 Introduction and Installation
    • Helm 3 Introduction an...
    👉🏼Helm 3 Deep Dive
    • Helm 3 Deep Dive
    👉🏼Docker Tutorial for Beginners Step by Step
    • Docker Tutorial for Be...
    👉🏼Docker Compose Tutorial
    • Docker Compose Tutorial
    👉🏼Install Minikube in Windows 10 via Docker Desktop
    • Install Minikube in Wi...
    👉🏼Kubernetes Minikube
    • Minikube
    👉🏼Kubernetes Core Concepts and Demo
    • Kubernetes Core Concep...
    👉🏼Kubernetes Advance and Demo
    • Kubernetes Adavance an...
    👋-----------------------------------------------------------------------------------
    Easy Connect:
    🏢 bit.ly/3tN3DeI
    🐦 bit.ly/3LF2q1Z

Komentáře • 4

  • @asadhanif3188
    @asadhanif3188 Před 6 měsíci +1

    As per your demo 4:50, CICD pipeline is triggering before approval and merging. I want it should be triggered after the code is merged.

    • @LianDuanTraining
      @LianDuanTraining  Před měsícem +1

      workflow:
      rules:
      - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_APPROVED == "true"
      Please try above new rules.

  • @ShabuThomas-ce6bi
    @ShabuThomas-ce6bi Před měsícem

    This not what you put in the title. You have not explained anything about how to trigger pipeline on merging the request. You just explained about how to trigger pipeline on creating a merge request.

    • @LianDuanTraining
      @LianDuanTraining  Před měsícem

      You're absolutely right; the explanation in the title did not fully cover triggering the pipeline upon merging the merge request. We apologize for any confusion this may have caused.
      To address this concern, we've updated the workflow rules to include a condition that triggers the pipeline upon merging the merge request. Now, the pipeline will run not only when the merge request is created but also when it is merged into the target branch.
      workflow:
      rules:
      - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_APPROVED == "true"