SuperAPI AI 工具集

syncing-test-providers

部署与运维

查看项目

更新于 10-15 14:30

技能介绍

用途

该技能用于在 DevOps Center 流水线上重新同步一个已配置的测试提供者(test provider),使自上次配置以来添加到该提供者的测试套件变为可用,从而可以分配到流水线阶段。

主要能力

  • 获取流水线上配置的所有测试提供者,解析 testProviderId 并与用户确认提供者名称。
  • 按状态(已配置 Configured 与可用 Available)分组展示提供者摘要。
  • 仅对已配置的提供者触发重新同步。
  • 通过 Connect API 的 sync 端点触发同步,支持一次调用同步多个已配置提供者(testProviderIds 为列表)。
  • 同步为异步执行,完成后新套件可再分配到阶段。

使用方式

前置条件

需先加载 checking-devops-prerequisites 技能,完成前置条件 1–4(组织登录、Agentforce DX 插件、DevOps Center 组织授权、识别流水线)。前置条件 5(阶段)不适用:提供者在流水线级别同步,而非阶段级别。

涉及变量:

  • doce-org-alias:在前置条件 1 中建立。
  • pipelineId:在前置条件 4(流水线选择)中识别。
  • testProviderId:通过获取流水线的测试提供者解析得到。

步骤 1 — 获取测试提供者以解析提供者 ID

获取流水线上配置的所有测试提供者,以解析 testProviderId 并与用户确认提供者名称:

sf api request rest \
  "/services/data/v67.0/connect/devopstesting/pipeline/<pipelineId>/testProviders?status=all" \
  --target-org <doce-org-alias>

每个提供者条目包含 testProviderId、testProviderName 和状态(Configured 与 Available)。按状态分组展示简短摘要:

Test providers for <pipelineName>:

✓ Configured:
- Code Analyzer (63 suites)
- Apex Unit Tests (5 suites)

Available (not yet configured):
- Flow Tests

仅已配置(Configured)的提供者可同步。若用户指定的是可用(尚未配置)的提供者,需说明必须先配置——本技能不负责配置提供者。

若流水线没有已配置的提供者,报告并停止——不要编造提供者或 ID。

步骤 2 — 确认关卡

必需——在用户确认前不得调用 API。

提示语:"I'll re-sync <testProviderName> on the <pipelineName> pipeline to pick up any new suites. Confirm?"

在用户给出肯定答复前不得继续。

步骤 3 — 触发同步

确认后,使用提供者 ID 和流水线 ID 调用 sync 端点:

sf api request rest \
  "/services/data/v67.0/connect/devops/sync" \
  --method POST \
  --body '{
    "testProviderIds": ["<testProviderId>"],
    "pipelineId": "<pipelineId>"
  }' \
  --target-org <doce-org-alias>

testProviderIds 是一个列表——可在一次调用中同步多个已配置的提供者。

成功后提示:"Provider <testProviderName> sync started. The operation is running asynchronously — new suites will be available shortly."

同步异步运行;新同步的套件随后可通过 managing-suite-assignments 分配到阶段。

关键注意事项

不要使用 POST /connect/devops/pipeline/<pipelineId>/testProvider 进行同步——该端点会创建新的提供者配置,导致重复的 DevopsPipelineTestProvider 记录。只能通过 POST /connect/devops/sync 同步。

错误处理

切勿向用户暴露原始 API 错误消息、堆栈跟踪或 JSON 载荷。将响应状态码映射为通俗语言消息:

  • 400:"The sync request was invalid. Check that the provider ID and pipeline ID are correct."
  • 403:"You don't have permission to sync test providers on this pipeline."
  • 404:"The pipeline or test provider was not found."
  • 500:"A server error occurred. Try again in a few minutes."

相关技能

  • checking-devops-prerequisites:首先加载以建立组织和流水线上下文。
  • configuring-test-provider:用于首次配置可用提供者;本技能仅重新同步已配置的提供者。
  • managing-suite-assignments:同步出现新套件后,用于将其分配或映射到流水线阶段。
  • recommending-devops-tests:用于推荐新同步套件中应运行哪些。

适用场景与限制

适用场景:DevOps Center 流水线上已配置的测试提供者需要重新同步以纳入新增测试套件时。

限制:仅能同步已配置的提供者;不负责配置提供者;需用户明确确认;同步为异步操作;需先完成前置条件 1–4。