极狐GitLab 外部流水线验证功能解读

极狐GitLab 是 GitLab 在中国的发行版,关于中文参考文档和资料有:

外部流水线验证 (BASIC SELF)

您可以使用外部服务在创建流水线之前进行验证。

极狐GitLab 发送一个 POST 请求到外部服务的 URL,并将流水线数据作为负载。外部服务的响应代码决定了极狐GitLab 是否应该接受或拒绝流水线。如果响应是:

  • 200,流水线被接受。

  • 406,流水线被拒绝。

  • 其他代码,流水线被接受并记录。

如果出现错误或请求超时,流水线将被接受。

由外部验证服务拒绝的流水线不会被创建,也不会出现在极狐GitLab 的 UI 或 API 的流水线列表中。如果您在 UI 中创建的流水线被拒绝,会显示 Pipeline cannot be run. External validation failed。

配置外部流水线验证

要配置外部流水线验证,请添加 EXTERNAL_VALIDATION_SERVICE_URL 环境变量 并将其设置为外部服务的 URL。

默认情况下,请求外部服务将在五秒后超时。要覆盖默认设置,请设置 EXTERNAL_VALIDATION_SERVICE_TIMEOUT 环境变量为所需的秒数。

负载架构

  • tag_list introduced in 极狐GitLab 16.11.
bash 复制代码
{
  "type": "object",
  "required" : [
    "project",
    "user",
    "credit_card",
    "pipeline",
    "builds",
    "total_builds_count",
    "namespace"
  ],
  "properties" : {
    "project": {
      "type": "object",
      "required": [
        "id",
        "path",
        "created_at",
        "shared_runners_enabled",
        "group_runners_enabled"
      ],
      "properties": {
        "id": { "type": "integer" },
        "path": { "type": "string" },
        "created_at": { "type": ["string", "null"], "format": "date-time" },
        "shared_runners_enabled": { "type": "boolean" },
        "group_runners_enabled": { "type": "boolean" }
      }
    },
    "user": {
      "type": "object",
      "required": [
        "id",
        "username",
        "email",
        "created_at"
      ],
      "properties": {
        "id": { "type": "integer" },
        "username": { "type": "string" },
        "email": { "type": "string" },
        "created_at": { "type": ["string", "null"], "format": "date-time" },
        "current_sign_in_ip": { "type": ["string", "null"] },
        "last_sign_in_ip": { "type": ["string", "null"] },
        "sign_in_count": { "type": "integer" }
      }
    },
    "credit_card": {
      "type": "object",
      "required": [
        "similar_cards_count",
        "similar_holder_names_count"
      ],
      "properties": {
        "similar_cards_count": { "type": "integer" },
        "similar_holder_names_count": { "type": "integer" }
      }
    },
    "pipeline": {
      "type": "object",
      "required": [
        "sha",
        "ref",
        "type"
      ],
      "properties": {
        "sha": { "type": "string" },
        "ref": { "type": "string" },
        "type": { "type": "string" }
      }
    },
    "builds": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "name",
          "stage",
          "image",
          "tag_list",
          "services",
          "script"
        ],
        "properties": {
          "name": { "type": "string" },
          "stage": { "type": "string" },
          "image": { "type": ["string", "null"] },
          "tag_list": { "type": ["array", "null"] },
          "services": {
            "type": ["array", "null"],
            "items": { "type": "string" }
          },
          "script": {
            "type": "array",
            "items": { "type": "string" }
          }
        }
      }
    },
    "total_builds_count": { "type": "integer" },
    "namespace": {
      "type": "object",
      "required": [
        "plan",
        "trial"
      ],
      "properties": {
        "plan": { "type": "string" },
        "trial": { "type": "boolean" }
      }
    },
    "provisioning_group": {
      "type": "object",
      "required": [
        "plan",
        "trial"
      ],
      "properties": {
        "plan": { "type": "string" },
        "trial": { "type": "boolean" }
      }
    }
  }
}

namespace 字段仅在 极狐GitLab 专业版和旗舰版 中可用。

相关推荐
小小小糖果人15 分钟前
Linux云计算基础篇(25)-DNS配置
linux·运维·云计算
TIANE-Kimmy27 分钟前
VS code定时任务设置(mac os)
linux·运维·服务器
panshiyangmaye39 分钟前
RHCSA作业1
linux·运维·服务器
Narutolxy1 小时前
从混合部署到高可用:在内网环境下搭建 GitLab-Jenkins-OpenResty的完整实战复盘20251014
gitlab·jenkins·openresty
馨谙2 小时前
标题:Linux 系统中的“保险库管理员”:深入浅出理解 /etc/shadow 文件
linux·运维·服务器
wadesir3 小时前
云服务器与传统服务器租用的核心差异解析(云服务器与服务器租用之间的区别在哪里?)
运维·服务器
凯子坚持 c3 小时前
Docker 深度解析:从虚拟化到新一代应用构建、运行与交付
运维·docker·容器
风吹落叶花飘荡3 小时前
启用服务器登录失败处理与超时自动退出功能
运维·服务器
乌萨奇也要立志学C++4 小时前
【Linux】基础IO(一)Linux 文件操作从入门到实践:系统调用、文件描述符、重定向,为自定义Shell添加重定向
linux·运维·chrome
嵌入式郑工9 小时前
LINUX驱动开发: 设备和驱动是怎么匹配的?
linux·运维·服务器