Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the ServiceEndpoinr.Uri as/in the SourceDefinition.Endpoint #973

Closed
jessehouwing opened this issue Dec 11, 2015 · 4 comments
Closed

Comments

@jessehouwing
Copy link
Contributor

See also: #801

We're trying to build a task for Build which will select a server based on the Generic Endpoints registered in VSTS or VSO. In a number of other dropdowns we want to provide a picklist by calling a REST api on the target endpoint.

We want this task to be generic and since the server product will be installed by clients, there is no "generic global unique uri" which we can query.

What we'd like to be able to do is this:

  "sourceDefinitions": [
    {
        "target": "targetEnvironment",
        "endpoint": "$(connectedServiceName.Url)/repository/query?type=udm.Environment",
        "selector": "xpath://list/ci/@ref",
        "authKey": "$(connectedServiceName)"
    }
  ],

But as mentioned in #801, there currently is no way to access the Generic Endpoint URL to make the call.

There could be multiple instances of this server product and we'd like to be able to provide a generic build task which will work for all and won't have to be customized for each installation with the correct local URI.

@GitHubSriramB
Copy link
Contributor

Here's what you could do:

  • Register a custom service endpoint type corresponding to the "server" that the Build task operates on.
  • Have one or more data sources (this is similar to source definitions that you mentioned above) in the custom endpoint type that the Build task requires to query to populate pick lists.
  • Create one or more endpoints of this custom endpoint type - each pointing to a different URL.
  • From the Build task, choose one of the endpoints that you are interested in

This should populate the picklist using the values returned by the specific endpoint your Build task is interested in,

For reference on creating custom endpoints you can refer to following examples:
microsoft/vsts-extension-samples#30
https://github.com/Microsoft/vsts-extension-build-release-tasks/blob/master/vss-extension.json
https://github.com/Microsoft/vsts-vmware/blob/master/src/vss-extension.json
https://github.com/Microsoft/google-play-vsts-extension/blob/master/vsts-extension-google-play.json

If you have any queries, pl. let us know. We will put together the details required to create a custom endpoint with dataSources in a write-up shortly that would help you here.

@mmajcica
Copy link
Contributor

@GitHubSriramB can you provide a working example of the technique you described? Let's assume that we have a custom endpoint called Foo, which will give us our list at address /repository/list1. How would you then bind the result of it to a pickList in your manifest file?

Thanks

@GitHubSriramB
Copy link
Contributor

@mmajcica - You can find how BitBucket download task is using data source binding for listing repositories which is very close to what you are asking for:
Here is the extension manifest file that includes the definition of the BitBucket endpoint contribution:
https://github.com/Microsoft/vsts-rm-extensions/blob/master/Extensions/BitBucket/Src/vss-extension.json

Here is the task manifest file:
https://github.com/Microsoft/vsts-rm-extensions/blob/master/Extensions/BitBucket/Src/Tasks/DownloadArtifactBitbucket/task.json

Here's how the datasourceBinding for repository input that the task takes looks like:
"dataSourceBindings": [
{
"target": "definition",
"endpointId": "$(connection)",
"dataSourceName": "Repositories",
"parameters":{
},
"resultTemplate": "{ "Value" : "{{{full_name}}}", "DisplayValue" : "{{{full_name}}}" }"
},

Here's how the datasource for repository looks like:
"dataSources": [
{
"name": "Repositories",
"endpointUrl": "{{{endpoint.url}}}/2.0/repositories?role=member",
"resultSelector": "jsonpath:$.values[*]"
},

Let me know if you have further queries.

@mmajcica
Copy link
Contributor

mmajcica commented Sep 9, 2016

Dear @GitHubSriramB ,

it worked perfectly. Your examples where helpful however even more helpful was this article https://www.visualstudio.com/en-us/docs/integrate/extensions/develop/service-endpoints.
One question in this regard. Seems that once the call to my own datasources is made, it adds Accept json header to the request. Is that true? How can I retrieve the call he makes? Any log file or similar?

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants