流式获取构建日志

OpenAPI 契约

方法
GET
路径
/api/v1/builds/{taskId}/logs/stream
认证
jwtBearer (bearer) OR automationKey (bearer)
响应状态
200 400 401 403 404 429 500
请求与响应 Schema
JSON
{
  "requestBody": {},
  "responses": {
    "200": {
      "description": "Build log event stream",
      "content": {
        "text/event-stream": {
          "format": "binary",
          "type": "string"
        }
      }
    },
    "400": {
      "description": "Invalid request",
      "content": {
        "application/json": {
          "$ref": "#/components/schemas/RequestError"
        }
      }
    },
    "401": {
      "description": "Authentication required or invalid",
      "content": {
        "application/json": {
          "$ref": "#/components/schemas/SecurityError"
        }
      }
    },
    "403": {
      "description": "Authenticated but not permitted",
      "content": {
        "application/json": {
          "$ref": "#/components/schemas/SecurityError"
        }
      }
    },
    "404": {
      "description": "Requested build was not found",
      "content": {
        "application/json": {
          "$ref": "#/components/schemas/ApiError"
        }
      }
    },
    "429": {
      "description": "HTTP rate limit or API-key NCU usage limit exceeded",
      "content": {
        "application/json": {
          "$ref": "#/components/schemas/RateLimitError"
        }
      }
    },
    "500": {
      "description": "Unexpected server error",
      "content": {
        "application/json": {
          "$ref": "#/components/schemas/ApiError"
        }
      }
    }
  }
}

使用 JWT 或带 build:read 的 nfy_ 密钥为构建打开 SSE 流。project task 还要求调用方对项目拥有有效 build:read capability;legacy 或 ad-hoc task 使用 exact-owner fallback。以从零开始的行偏移启动,可在客户端断线后续传。每个新行以 log 事件发送。任务到达成功、失败或取消且流追上末尾后,会发送 done 并关闭。

流有有限的服务端生命周期,客户端必须处理断线。用已消费的行数重连,或用分页日志接口建立安全偏移。流开始前会检查认证和资源授权;日志不存在本身不代表终态。