在开发Azure DevOps扩展时无法使用resultSelector



我正在为Azure Devops开发一个自定义扩展,该扩展已经包含一个服务端点:

"type": "ms.vss-endpoint.service-endpoint-type"

此外,我想创建一个自定义的发布工件来源:

“type”: “ms.vss-releaseartifact.release-artifact-type”

根据这篇文档,我目前的困难是使用外部API填充Artifact Source下的字段。我在下面的"resultSelector"one_answers"resultTemplate"中尝试了许多模式,但没有找到一个对我有效的模式。

在我的示例中,我希望在json响应中的"builds"下获取所有"uri"值,并将它们呈现在Artifact Source的"definition"inputDescriptor中。我的所有尝试都导致了一个空的组合框,尽管我可以看到请求到达了所需的API。

我想解析到组合框中的json:

{
"builds": [
{
"uri": "/build1",
"lastStarted": "2018-11-07T13:12:42.547+0000"
},
{
"uri": "/build2",
"lastStarted": "2018-11-09T15:40:30.315+0000"
},
{
"uri": "/build3",
"lastStarted": "2018-11-12T17:46:24.805+0000"
}
],
"uri": "https://<server-address>/api/build"
}

你能帮我创建Mustache模式来检索上面的"uri"值吗
我试过了:

$.builds[*].uri

这似乎不起作用。

这里有一些更多的信息,以防有帮助。

服务端点的数据源:

"dataSources": [
{
"name": "TestConnection",
"endpointUrl": "{{endpoint.url}}/api/plugins",
"resourceUrl": "",
"resultSelector": "jsonpath:$.values[*]",
"headers": [],
"authenticationScheme": null
},
{
"name": "BuildNames",
"endpointUrl": "{{endpoint.url}}/api/build",
"resultSelector": "jsonpath:$.builds[*].uri"
},
{
"name": "BuildNumbers",
"endpointUrl": "{{endpoint.url}}/api/builds/{{definition}}",
"resultSelector": "jsonpath:$.buildsNumbers[*].uri"
}
]

工件来源:

"inputDescriptors": [
{
"id": "connection",
"name": "Artifactory service",
"inputMode": "combo",
"isConfidential": false,
"hasDynamicValueInformation": true,
"validation": {
"isRequired": true,
"dataType": "string",
"maxLength": 300
}
},
{
"id": "definition",
"name": "definition",
"description": "Name of the build.",
"inputMode": "combo",
"isConfidential": false,
"dependencyInputIds": [
"connection"
],
"validation": {
"isRequired": true,
"dataType": "string",
"maxLength": 300
}
},
{
"id": "buildNumber",
"name": "Build Number",
"description": "Number of the build.",
"inputMode": "combo",
"isConfidential": false,
"dependencyInputIds": [
"connection"
],
"validation": {
"isRequired": true,
"dataType": "string",
"maxLength": 300
}
}
],
"dataSourceBindings": [
{
"target": "definition",
"dataSourceName": "BuildNames",
"resultTemplate": "{ Value : "{{uri}}", DisplayValue : "{{uri}}" }"
},
{
"target": "versions",
"dataSourceName": "BuildNumbers",
"resultTemplate": "{ Value : "{{uri}}", DisplayValue : "{{uri}}" }"
},
{
"target": "latestVersion",
"dataSourceName": "BuildNumbers",
"resultTemplate": "{ Value : "{{uri}}", DisplayValue : "{{uri}}" }"
},
{
"target": "artifactDetails",
"resultTemplate": "{ Name: "{{version}}", downloadUrl : "{{endpoint.url}}" }"
},
{
"target": "buildNumber",
"dataSourceName": "BuildNumbers",
"resultTemplate": "{ Value : "{{uri}}", DisplayValue : "{{uri}}" }"
}
]
}

如有任何帮助,我们将不胜感激。

这种情况的工作组合是:

数据来源:

{
"name": "BuildNames",
"endpointUrl": "{{endpoint.url}}/api/build",
"resultSelector": "jsonpath:$.builds[*]"
}

dataSourceBindings:

{
"target": "definition",
"dataSourceName": "BuildNames",
"resultTemplate": "{ "Value" : "{{{uri}}}", "DisplayValue" : "{{{uri}}}" }"
}

相关内容

  • 没有找到相关文章

最新更新