Help us learn about your current experience with the documentation. Take the survey.
外部流水线验证
- 版本: Free, Premium, Ultimate
- 提供方式: GitLab Self-Managed
您可以使用外部服务在流水线创建前对其进行验证。
GitLab 会向外部服务 URL 发送一个 POST 请求,并将流水线数据作为请求体。外部服务的响应代码决定了 GitLab 应该接受还是拒绝该流水线。如果响应是:
200,流水线被接受。406,流水线被拒绝。- 其他代码,流水线被接受并记录日志。
如果出现错误或请求超时,流水线将被接受。
被外部验证服务拒绝的流水线不会被创建,也不会出现在 GitLab UI 或 API 的流水线列表中。如果您在 UI 中创建的流水线被拒绝,将显示 Pipeline cannot be run. External validation failed。
配置外部流水线验证
要配置外部流水线验证,请添加
EXTERNAL_VALIDATION_SERVICE_URL 环境变量
并将其设置为外部服务的 URL。
默认情况下,对外部服务的请求在五秒后超时。要覆盖默认值,请将 EXTERNAL_VALIDATION_SERVICE_TIMEOUT 环境变量设置为所需的秒数。
负载模式
{
"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 Premium 和 Ultimate 版本中可用。