JSON 结构对比可运行案例
流水线运行:解释 pipelines 首部插入导致的多处差异
数组按下标逐项比较。在 pipelines 开头插入记录后,后续元素位置移动,会产生多处修改和一个尾部新增;这不等于多条业务记录都发生了真实字段变更。需要按 ID 配对时应先在自己的业务逻辑中处理。
试一试
在完整工具中打开 ↗示例工作台
JSON 结构对比修改下方数据后重新运行
运行结果
[
{
"op": "replace",
"path": "/data/pipelines/0/pipelineId",
"oldValue": "demo-pipelines-1",
"value": "demo-inserted"
},
{
"op": "replace",
"path": "/data/pipelines/0/name",
"oldValue": "演示构建流水线",
"value": "新增演示记录"
},
{
"op": "replace",
"path": "/data/pipelines/1/pipelineId",
"oldValue": "demo-pipelines-2",
"value": "demo-pipelines-1"
},
{
"op": "replace",
"path": "/data/pipelines/1/name",
"oldValue": "演示测试流水线",
"value": "演示构建流水线"
},
{
"op": "replace",
"path": "/data/pipelines/1/durationSeconds",
"oldValue": 95,
"value": 42
},
{
"op": "replace",
"path": "/data/pipelines/1/passed",
"oldValue": false,
"value": true
},
{
"op": "replace",
"path": "/data/pipelines/1/stage",
"oldValue": "test",
"value": "build"
},
{
"op": "replace",
"path": "/data/pipelines/1/execution/runner",
"oldValue": "demo-runner-b",
"value": "demo-runner-a"
},
{
"op": "replace",
"path": "/data/pipelines/1/execution/jobs/0",
"oldValue": "unit",
"value": "compile"
},
{
"op": "remove",
"path": "/data/pipelines/1/execution/jobs/1",
"oldValue": "integration"
},
{
"op": "add",
"path": "/data/pipelines/2",
"value": {
"pipelineId": "demo-pipelines-2",
"name": "演示测试流水线",
"durationSeconds": 95,
"passed": false,
"stage": "test",
"execution": {
"runner": "demo-runner-b",
"jobs": [
"unit",
"integration"
]
}
}
}
]原例已核验,可修改输入后重新运行。
⌘ / Ctrl + Enter 运行01
场景与操作说明
流水线状态需要结合阶段和作业终态判断。此页面只比较运行样本,不触发构建、测试或部署。
durationSeconds 采用秒,与日志中的毫秒字段比较前需换算。
- 核对 流水线运行 的字段层级,保留 pipelineId 的字符串类型。
- 修改一项输入并运行,观察结果中的值或路径如何变化。
- 载入对照样本,复现下面的变化;恢复原例会替换当前输入。
02
对照样本
对照样本交换 A 与 B。观察新增与删除的方向、修改前后值如何反转;没有差异时交换仍无差异。
查看对照输入
{
"ok": true,
"data": {
"pipelines": [
{
"pipelineId": "demo-inserted",
"name": "新增演示记录",
"durationSeconds": 42,
"passed": true,
"stage": "build",
"execution": {
"runner": "demo-runner-a",
"jobs": [
"compile"
]
}
},
{
"pipelineId": "demo-pipelines-1",
"name": "演示构建流水线",
"durationSeconds": 42,
"passed": true,
"stage": "build",
"execution": {
"runner": "demo-runner-a",
"jobs": [
"compile"
]
}
},
{
"pipelineId": "demo-pipelines-2",
"name": "演示测试流水线",
"durationSeconds": 95,
"passed": false,
"stage": "test",
"execution": {
"runner": "demo-runner-b",
"jobs": [
"unit",
"integration"
]
}
}
],
"summary": {
"total": 2,
"note": null
}
}
}{
"ok": true,
"data": {
"pipelines": [
{
"pipelineId": "demo-pipelines-1",
"name": "演示构建流水线",
"durationSeconds": 42,
"passed": true,
"stage": "build",
"execution": {
"runner": "demo-runner-a",
"jobs": [
"compile"
]
}
},
{
"pipelineId": "demo-pipelines-2",
"name": "演示测试流水线",
"durationSeconds": 95,
"passed": false,
"stage": "test",
"execution": {
"runner": "demo-runner-b",
"jobs": [
"unit",
"integration"
]
}
}
],
"summary": {
"total": 2,
"note": null
}
}
}对照样本的实际结果
[
{
"op": "replace",
"path": "/data/pipelines/0/pipelineId",
"oldValue": "demo-inserted",
"value": "demo-pipelines-1"
},
{
"op": "replace",
"path": "/data/pipelines/0/name",
"oldValue": "新增演示记录",
"value": "演示构建流水线"
},
{
"op": "replace",
"path": "/data/pipelines/1/pipelineId",
"oldValue": "demo-pipelines-1",
"value": "demo-pipelines-2"
},
{
"op": "replace",
"path": "/data/pipelines/1/name",
"oldValue": "演示构建流水线",
"value": "演示测试流水线"
},
{
"op": "replace",
"path": "/data/pipelines/1/durationSeconds",
"oldValue": 42,
"value": 95
},
{
"op": "replace",
"path": "/data/pipelines/1/passed",
"oldValue": true,
"value": false
},
{
"op": "replace",
"path": "/data/pipelines/1/stage",
"oldValue": "build",
"value": "test"
},
{
"op": "replace",
"path": "/data/pipelines/1/execution/runner",
"oldValue": "demo-runner-a",
"value": "demo-runner-b"
},
{
"op": "replace",
"path": "/data/pipelines/1/execution/jobs/0",
"oldValue": "compile",
"value": "unit"
},
{
"op": "add",
"path": "/data/pipelines/1/execution/jobs/1",
"value": "integration"
},
{
"op": "remove",
"path": "/data/pipelines/2",
"oldValue": {
"pipelineId": "demo-pipelines-2",
"name": "演示测试流水线",
"durationSeconds": 95,
"passed": false,
"stage": "test",
"execution": {
"runner": "demo-runner-b",
"jobs": [
"unit",
"integration"
]
}
}
}
]