我正在为Azure Devops开发一个自定义扩展,它已经包含一个服务端点:
"type": "ms.vss-endpoint.service-endpoint-type"
另外,我想创建一个自定义的Release Artifact Source:
“type”: “ms.vss-releaseartifact.release-artifact-type”
在this documentation之后,我目前的努力是使用外部API填充Artifact Source下的字段.我在下面的’resultSelector’和’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.","dependencyInputIds": [ "connection" ],"maxLength": 300 } },{ "id": "buildNumber","name": "Build Number","description": "Number of the build.","dependencyInputIds": [ "connection" ],"validation": { "isrequired": true,"maxLength": 300 } } ],"dataSourceBindings": [ { "target": "definition","dataSourceName": "BuildNames","resultTemplate": "{ Value : \"{{uri}}\",DisplayValue : \"{{uri}}\" }" },{ "target": "versions","dataSourceName": "BuildNumbers",{ "target": "latestVersion",{ "target": "artifactDetails","resultTemplate": "{ Name: \"{{version}}\",downloadUrl : \"{{endpoint.url}}\" }" },{ "target": "buildNumber",DisplayValue : \"{{uri}}\" }" } ] }
我们将非常感谢您提供的任何帮助.
解决方法
这种情况的工作组合是:
数据源:
{ "name": "BuildNames","resultSelector": "jsonpath:$.builds[*]" }
dataSourceBindings:
{ "target": "definition","resultTemplate": "{ \"Value\" : \"{{{uri}}}\",\"DisplayValue\" : \"{{{uri}}}\" }" }