azure-devopsazure-pipelinesazure-devops-extensionsserviceconnection

How to list my service connection in New Service Connection in Azure DevOps?


This is my contributions in vss-extension.json file, but it is not visible in the Azure Devops Page (I have installed the extension).

The azure devops documentation says that this is enough to show the New service connection - https://learn.microsoft.com/en-us/azure/devops/extend/develop/service-endpoints?view=azure-devops

PS: I also have one agentless task in my extension.

{
            "id": "sample-service-connection",
            "type": "ms.vss-endpoint.service-endpoint-type",
            "targets": [
                "ms.vss-endpoint.endpoint-types"
            ],
            "properties": {
                "name": "sampleChangeManagement",
                "displayName": "sample Change Management",
                "helpMarkDown": "Connect to Sample to manage sample in Azure DevOps Pipelines",
                "url": {
                    "displayName": "Sample URL",
                    "description": "The URL of your sample account, e.g. https://yourcompany.google.com"
                },
                "inputDescriptors": [
                    {
                        "id": "url",
                        "description": "Sample URL",
                        "inputMode": "textbox",
                        "isConfidential": false,
                        "validation": {
                            "isRequired": true,
                            "dataType": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "authenticationSchemes": [
                    {
                        "type": "ms.vss-endpoint.endpoint-auth-scheme-token"
                    },
                    {
                        "type": "ms.vss-endpoint.endpoint-auth-scheme-basic",
                        "inputDescriptors": [
                            {
                                "id": "username",
                                "name": "Username",
                                "description": "Username",
                                "inputMode": "textbox",
                                "validation": {
                                    "isRequired": false,
                                    "dataType": "string"
                                }
                            },
                            {
                                "id": "password",
                                "name": "Password",
                                "description": "Password",
                                "inputMode": "passwordbox",
                                "isConfidential": true,
                                "validation": {
                                    "isRequired": false,
                                    "dataType": "string"
                                }
                            }
                        ]
                    }
                ]
            }
        }

enter image description here I could not find any documentation other than adding this contribution, Can someone help me out? TIA :)


Solution

  • Based on your requirement, you need to add a custom endpoint to the Azure DevOps.

    Refer to the sample in the doc: Create a service endpoint You need to place the contributions to the correct field.

    You can use the following vss-extension.json sample:

    {
      "manifestVersion": 1,
      "id": "service-endpoint-tutorial",
      "version": "0.1.1",
      "name": "Sample extension that leverages a service endpoint",
      "description": "A sample Azure DevOps extension which shows how to create a custom endpoint and dynamic build task parameters taking value from a REST API.",
      "publisher": "publishername",
      "targets": [
        {
          "id": "Microsoft.VisualStudio.Services"
        }
      ],
      "categories": [
        "Azure Pipelines"
      ],
      "files": [
        {
          "path": "BuildTaskFolder"
        }
      ],
      "contributions": [
        {
          "id": "service-endpoint",
          "description": "Service endpoint type for Fabrikam connections",
          "type": "ms.vss-endpoint.service-endpoint-type",
          "targets": [ "ms.vss-endpoint.endpoint-types" ],
          "properties": {
            "name": "fabrikam",
            "displayName": "Fabrikam server connection",
            "url": {
              "displayName": "Server Url",
              "helpText": "Url for the Fabrikam server to connect to."
            },
            "dataSources": [
              {
                "name": "Fabrikam Projects",
                "endpointUrl": "{{endpoint.url}}api/projects/index",
                "resultSelector": "jsonpath:$[*].nm"
              }
    
            ],
            "authenticationSchemes": [
              {
                "type": "ms.vss-endpoint.endpoint-auth-scheme-token"
              },
              {
                "type": "ms.vss-endpoint.endpoint-auth-scheme-basic",
                "inputDescriptors": [
                  {
                    "id": "username",
                    "name": "Username",
                    "description": "Username",
                    "inputMode": "textbox",
                    "validation": {
                      "isRequired": false,
                      "dataType": "string"
                    }
                  },
                  {
                    "id": "password",
                    "name": "Password",
                    "description": "Password",
                    "inputMode": "passwordbox",
                    "isConfidential": true,
                    "validation": {
                      "isRequired": false,
                      "dataType": "string"
                    }
                  }
                ]
              }
    
            ],
            "helpMarkDown": "<a href=\"url-to-documentation\" target=\"_blank\"><b>Learn More</b></a>"
          }
        },
        {
          "id": "build-task",
          "description": "Task with a dynamic property getting data from an endpoint REST data source",
          "type": "ms.vss-distributed-task.task",
          "targets": [ "ms.vss-distributed-task.tasks" ],
          "properties": {
            "name": "BuildTaskFolder"
          }
        }
      ]
    }
    

    After installing the custom extension, the custom service endpoint type will show in the list.

    Result:

    enter image description here

    Here are the existing sample and additional docs you can refer to:

    Sample: Extension sample and ms.vss-endpoint.service-endpoint-type

    Docs: Service endpoints - Customization