Logo Gitlab Cicd Pipeline Design

Gitlab Cicd Pipeline Design

Cộng đồng
selvarajmurugesan90
gitlab-cicd-pipeline-design

Authors and troubleshoots .gitlab-ci.yml pipelines — stages, the modern rules: syntax (and legacy only/except), includes for shared templates, and GitLab-specific runner/executor configuration. Use when the user asks to "write a .gitlab-ci.yml," "fix a GitLab pipeline rule that isn't triggering," "add a shared CI template with include," "set up a GitLab runner," or "convert only/except rules to the rules: syntax."

Tổng quan

Nhà phát hànhselvarajmurugesan90
Kho mãops-engineering-skills
Tên kỹ nănggitlab-cicd-pipeline-design
Sao
44
Bản fork
18
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được selvarajmurugesan90 công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Gitlab Cicd Pipeline Design trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/selvarajmurugesan90/ops-engineering-skills/tree/main/plugins/cicd-tooling/skills/gitlab-cicd-pipeline-design
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/selvarajmurugesan90/ops-engineering-skills.git /tmp/ops-engineering-skills
mkdir -p .claude/skills
cp -r /tmp/ops-engineering-skills/plugins/cicd-tooling/skills/gitlab-cicd-pipeline-design .claude/skills/gitlab-cicd-pipeline-design
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Gitlab Cicd Pipeline Design trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Gitlab Cicd Pipeline Design ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Gitlab Cicd Pipeline Design với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

GitLab CI/CD Pipeline Design

Purpose

GitLab CI/CD pipelines are defined entirely in one file, .gitlab-ci.yml, executed by GitLab Runners (shared, group, or project-specific) against a stages:/rules: model that differs in specifics from GitHub Actions or Jenkins even though the underlying pipeline concepts overlap (see ci-cd-pipeline-design for the vendor-neutral version). This skill covers GitLab-specific mechanics: the stages:/rules: trigger model (and why rules: has superseded the legacy only:/except:), include: for sharing pipeline templates across projects, and runner/executor configuration specifics.

When to use

  • A project needs its first .gitlab-ci.yml, or an existing one has a job that isn't running (or runs) when expected.
  • Migrating legacy only:/except: job keywords to the modern rules: syntax.
  • Sharing pipeline logic across multiple projects via include: (local, project, remote, or template includes) rather than duplicating YAML.
  • Diagnosing why a job is stuck pending (no runner picks it up) or fails only on certain runners.
  • Designing merge-request pipelines (merge_request_event) alongside branch/tag pipelines without running both redundantly on the same commit.

Prerequisites & environment

  • GitLab 15+ recommended: the rules: keyword and modern workflow: block are fully mature from GitLab 13+, but 15+ is assumed here for current defaults and deprecation warnings around only:/except:.
  • At least one available GitLab Runner registered against the project, group, or instance, with an executor type understood (shell, docker, docker+machine, kubernetes) — job tags: must match a runner's configured tags or the job stays pending forever.
  • Project or group maintainer access to configure CI/CD variables (Settings → CI/CD → Variables, marked "Protected"/"Masked" as appropriate) and to register runners.
  • For include: of remote/template files: network access from the GitLab instance to the include source (for include: remote:), or access to the referenced project (for include: project:).

Step-by-step guidance

  1. Declare stages: explicitly — job execution order follows stage order, and jobs within the same stage run in parallel by default:

    yaml
    stages:
      - lint
      - test
      - build
      - deploy
  2. Use workflow: to control whether a pipeline runs at all, before worrying about individual job rules — this avoids running duplicate pipelines for the same commit (once as a branch pipeline, once as a merge-request pipeline):

    yaml
    workflow:
      rules:
        - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
        - if: '$CI_COMMIT_BRANCH == "main"'
        - if: '$CI_COMMIT_TAG'
  3. Use rules: on each job, not the legacy only:/except:. rules: evaluates a list of conditions top-to-bottom and uses the first match, supporting changes:, if:, and exists: in combination — expressiveness only:/except: can't match:

    yaml
    deploy-staging:
      stage: deploy
      rules:
        - if: '$CI_COMMIT_BRANCH == "main"'
          changes:
            - src/**/*
      script:
        - ./deploy.sh staging

    only:/except: still parses and runs in current GitLab, but new pipelines should use rules: — it's the only mechanism that gets new condition types going forward, and mixing both styles in the same project is a common source of confusing, hard-to-predict trigger behavior.

  4. Use changes: for monorepo path filtering so an unrelated change doesn't trigger a full pipeline:

    yaml
    test-backend:
      stage: test
      rules:
        - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
          changes:
            - backend/**/*
      script:
        - cd backend && npm ci && npm test
  5. Share pipeline templates across projects with include: — local for same-repo files, project/remote for cross-repo/ cross-instance shared templates, template for GitLab's built-in templates:

    yaml
    include:
      - project: 'platform/ci-templates'
        ref: 'v2.1.0'
        file: '/templates/node-service.yml'
      - local: '/.gitlab/ci/deploy.yml'

    Pin ref: to a tag for a project: include, the same versioning discipline as a Jenkins shared library or GitHub Actions reusable workflow — an unpinned ref: main include means every consumer's pipeline changes the moment the template repo's main branch changes.

  6. Configure caching keyed on lockfile hash, scoped per-job or shared:

    yaml
    test:
      stage: test
      cache:
        key:
          files: [package-lock.json]
        paths:
          - node_modules/
      script:
        - npm ci
        - npm test
  7. Match tags: to actual runner capabilities — a job with tags: [docker, linux] only runs on a runner registered with both tags; a mismatch leaves the job pending indefinitely with no error message beyond the pending state itself:

    yaml
    build:
      stage: build
      tags: [docker]
      script:
        - docker build -t myapp:$CI_COMMIT_SHORT_SHA .
  8. Gate production deploys with environment: and when: manual, giving GitLab's UI a visible "play" button and (with a protected environment) restricting who can trigger it:

    yaml
    deploy-production:
      stage: deploy
      rules:
        - if: '$CI_COMMIT_BRANCH == "main"'
          when: manual
      environment:
        name: production
        url: https://app.example.com
      script:
        - ./deploy.sh production

Best practices

  • Standardize on rules: across the project; don't mix only:/except: and rules: in the same .gitlab-ci.yml — the interaction between the two legacy and modern mechanisms on different jobs is a frequent source of "why did this job run/not run" confusion.
  • Set workflow:rules once at the top of the file to prevent duplicate branch + merge-request pipelines firing for the same commit, rather than trying to fix it job-by-job.
  • Pin include: refs to tags for cross-project templates; treat the template repo like any other shared library with semantic versioning and a changelog.
  • Use protected environments (Settings → CI/CD → Environments) plus when: manual together for production deploys — when: manual alone only adds a button, it doesn't restrict who can press it without a protected environment's approval rules.
  • Use needs: to express real job dependencies within/across stages for a DAG-style pipeline (jobs start as soon as their specific needs: are done, not only after the whole previous stage finishes) when stage-by-stage sequencing is unnecessarily slow.
  • Emit JUnit reports via artifacts: reports: junit: so failures surface in the merge request UI directly rather than only in job logs.

Common pitfalls

  • Symptom: A job that should run on merge requests runs twice — once as a "detached" merge request pipeline, once again as a branch pipeline after merge, and both look like separate, sometimes contradictory states in the merge request widget. Fix: Add a top-level workflow:rules: block that picks exactly one pipeline source per commit context (merge_request_event OR $CI_COMMIT_BRANCH == "main"), rather than letting both branch and merge-request pipelines trigger unconditionally.

  • Symptom: A job sits in pending status indefinitely with no runner ever picking it up, and no clear error is shown. Fix: Check that the job's tags: match a registered, active runner's tags exactly (Settings → CI/CD → Runners to see available runners and their tags) — a job with a tag no runner advertises stays pending forever rather than failing loudly.

  • Symptom: Converting only: [main] to rules: - if: '$CI_COMMIT_BRANCH == "main"' changes behavior unexpectedly — the job now also runs (or stops running) on merge request pipelines. Fix: only:/except: and rules: have different implicit defaults for pipeline source; when migrating, be explicit about which CI_PIPELINE_SOURCE values a job should match rather than assuming a 1:1 semantic translation, and check pipeline behavior on both a branch push and an MR event after migrating.

  • Symptom: A remote/project include: pointed at a template repo's ref: main silently changes every consuming project's pipeline the moment someone merges to that template repo's main. Fix: Pin ref: to a specific tag (ref: 'v2.1.0') for any cross-project include, and roll out template changes via a version bump in each consumer, not a floating branch reference.

  • Symptom: deploy-production has when: manual but any developer with basic project access can trigger it, bypassing an intended approval step. Fix: when: manual alone only adds a manual trigger button — pair it with a protected environment (Settings → CI/CD → Environments) restricted to specific users/groups/roles to actually gate who can press it, mirroring the manual-approval-gate guidance in ci-cd-pipeline-design.

Worked example

Scenario: A monorepo with a backend/ and frontend/ directory needs path-filtered pipelines (only test what changed), a shared lint template pulled from a central templates project, and a manually-gated production deploy restricted to a protected environment.

.gitlab-ci.yml:

yaml
stages: [lint, test, build, deploy]

workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH == "main"'

include:
  - project: 'platform/ci-templates'
    ref: 'v2.1.0'
    file: '/templates/eslint.yml'

test-backend:
  stage: test
  tags: [docker]
  rules:
    - changes:
        - backend/**/*
  cache:
    key: { files: [backend/package-lock.json] }
    paths: [backend/node_modules/]
  script:
    - cd backend && npm ci && npm test

test-frontend:
  stage: test
  tags: [docker]
  rules:
    - changes:
        - frontend/**/*
  cache:
    key: { files: [frontend/package-lock.json] }
    paths: [frontend/node_modules/]
  script:
    - cd frontend && npm ci && npm test

build-image:
  stage: build
  tags: [docker]
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
  script:
    - docker build -t myapp:$CI_COMMIT_SHORT_SHA .

deploy-production:
  stage: deploy
  tags: [docker]
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
      when: manual
  environment:
    name: production
    url: https://app.example.com
  script:
    - ./deploy.sh production $CI_COMMIT_SHORT_SHA

With production configured as a protected environment restricted to the release-managers group, a change to only frontend/ skips test-backend entirely, and deploy-production waits for both a main merge and an authorized manual trigger.

Cross-references

Câu hỏi thường gặp

Kỹ năng AI Gitlab Cicd Pipeline Design làm được gì?

Authors and troubleshoots .gitlab-ci.yml pipelines — stages, the modern rules: syntax (and legacy only/except), includes for shared templates, and GitLab-specific runner/executor configuration. Use when the user asks to "write a .gitlab-ci.yml," "fix a GitLab pipeline rule that isn't triggering," "add a shared CI template with include," "set up a GitLab runner," or "convert only/except rules to the rules: syntax."

Vì sao nên dùng Gitlab Cicd Pipeline Design trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Gitlab Cicd Pipeline Design là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Gitlab Cicd Pipeline Design trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/selvarajmurugesan90/ops-engineering-skills/tree/main/plugins/cicd-tooling/skills/gitlab-cicd-pipeline-design. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Gitlab Cicd Pipeline Design?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Gitlab Cicd Pipeline Design với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Gitlab Cicd Pipeline Design với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Gitlab Cicd Pipeline Design có miễn phí không?

Có. Kỹ năng này được selvarajmurugesan90 phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇