【问题标题】:Azure DevOps Extension custom service endopint for ID/KEYID/KEY 的 Azure DevOps Extension 自定义服务终结点
【发布时间】:2019-04-03 06:06:16
【问题描述】:

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

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

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

是否可以从上面的对话框中删除服务器 URL 或者我可以使用更好的端点类型来满足这个要求?请善待与我分享一些光明。

【问题讨论】:

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


    【解决方案1】:

    您需要创建一个自定义服务类型,以便显示/隐藏各个文本框。你可以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

    【讨论】:

    • 谢谢。我会试试这个
    • 我刚刚制作了 "isVisible": "false" 效果很好
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-26
    相关资源
    最近更新 更多