用于ID / KEY的Azure DevOps Extension定制服务Endopint

时间:2018-10-30 08:33:48

标签: tfs azure-devops azure-devops-rest-api azure-devops-extensions

我正在开发Azure DevOps扩展,其中包含用于保存秘密ID / KEY的服务终结点。我的要求是使端点仅由连接名称,ID和键组成。我已经查看了Microsoft提供的端点列表,但找不到合适的选项来满足我的要求。

https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=vsts#sep-ssh

我发现的最接近的解决方案如下。但是它包含服务器URL的输入框(我需要省略(在此示例中,尽管我没有定义它显示在弹出对话框中的服务器URL))。请参考下图。

enter image description here

是否可以从上面的对话框中删除服务器URL,或者可以使用更好的终结点类型来满足此要求?请足够和我分享一些光线。

1 个答案:

答案 0 :(得分:3)

您需要创建一个自定义服务类型,该服务类型将允许您显示/隐藏各个文本框。您可以find an example in the Azure DevOps Extension Tasks which I maintain

您在vss-extension.json中定义自定义服务端点类型以及其他扩展点:

{
      "id": "vsts-marketplace-endpoint-type",
      "type": "ms.vss-endpoint.service-endpoint-type",
      "targets": [
        "ms.vss-endpoint.endpoint-types"
      ],
      "properties": {
        "name": "VstsMarketplacePublishing",
        "displayName": "Visual Studio Marketplace",
        "url": {
          "displayName": "Marketplace URL",
          "value": "https://marketplace.visualstudio.com",
          "isVisible": "false" 
        },
        "helpMarkDown": "Required permissions: <ul><li><b>Publish</b>: All accessible organisations, Marketplace (Publish)</li><li><b>Share</b>: All accessible organisations, Marketplace Publish</li><li><b>Install</b>: All accessible organisations or a specific organisation, Extensions (read and manage), Marketplace (acquire)</li><li><b>Query Version</b>: All accessible organisations, Marketplace (read)</li><li><b>Is Valid Extension</b>: All accessible organisations, Marketplace (read)</li></ul><br/><a href='https://www.visualstudio.com/docs/setup-admin/team-services/use-personal-access-tokens-to-authenticate'>More information</a>.",
        "authenticationSchemes": [
          {
            "type": "ms.vss-endpoint.endpoint-auth-scheme-basic",
            "inputDescriptors": [
              {
                "id": "username",
                "name": "Username",
                "description": "Username",
                "inputMode": "textbox",
                "isConfidential": false,
                "validation": {
                  "isRequired": false,
                  "dataType": "string",
                  "maxLength": 300
                },
                "values": {
                  "inputId": "username",
                  "isDisabled": true,
                  "defaultValue": ""
                }
              },
              {
                "id": "password",
                "name": "Personal access token",
                "description": "Azure DevOps personal access token.",
                "inputMode": "passwordbox",
                "isConfidential": true,
                "validation": {
                  "isRequired": true,
                  "dataType": "string",
                  "maxLength": 300
                }
              }
            ]
          }
        ]
      }
    },

您可能会找到other extensions that set or configure the authentication dialog on GitHub, there are quite a few。有用的docs are here in an old blog post