Skip to content

GitLab CI

一句话解释

GitLab CI 是 GitLab's integrated CI/CD service 那个运行流水线定义 in .gitlab-CI.yml file.

用大白话说

GitLab CI 是 CI/CD service 构建到 GitLab. 你定义流水线 in .gitlab-ci.yml file at the root of your repository, and GitLab automatically runs them on every push or merge request.

A pipeline consists of stages, and each stage contains jobs. Jobs run in runners — either GitLab's shared runners or your own self-hosted runners. GitLab CI is known for its clean YAML syntax and tight integration with GitLab features like merge requests and environments.

GitLab CI is included in GitLab (even the free CE edition), making it a popular choice for teams already using GitLab for source control.

示例

yaml
stages:
  - build
  - test
  - deploy

build:
  stage: build
  script:
    - npm run build

test:
  stage: test
  script:
    - npm test

deploy:
  stage: deploy
  script:
    - kubectl apply -f k8s/
  only:
    - main

这个 .gitlab-CI.yml 定义 three stages: 构建, 测试, and 部署 (部署仅 运行 on 主要分支).

工作原理

  1. You create a .gitlab-ci.yml file in your repo root.
  2. GitLab detects a push and creates a pipeline.
  3. Jobs run in stages on available runners.
  4. Results show in GitLab's pipeline UI with logs and artifacts.

常见混淆

  • 容易混淆的对象: GitHub 操作

    关键区别: GitLab CI 是 for GitLab 仓库; GitHub 操作是 for GitHub 仓库. 两者都是 构建-in CI/CD services for 它们的 respective platforms.

相关术语

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表