如何获取 VSTS 任务的端点凭据

How to get endpoint credentials for VSTS task

我有以下 VSTS 任务和输入:

 {
      "name": "ConnectedServiceName",
      "type": "connectedService:Azure",
      "label": "Azure Subscription",
      "defaultValue": "",
      "required": true,
      "helpMarkDown": "Select the Azure subscription for the deployment. Only the supported Azure service connections are displayed and they are of the authentication type of Credentials or Service Principals."
    },

和task.js

var path = require('path');
var tl = require('vso-task-lib');

var echo = new tl.ToolRunner(tl.which('KeyVaultSecretManager.exe', true));
var auth = tl.getEndpointAuthorization(tl.getInput("ConnectedServiceName", true));

echo.arg(tl.getEndpointUrl(tl.getInput("ConnectedServiceName", true)) + " " + (typeof auth.parameters.servicePrincipalId) + " " + auth.parameters.servicePrincipalId + " " + auth.parameters.servicePrincipalKey + " " + JSON.stringify(auth));

echo.exec({ failOnStdErr: false })
.then(function (code) {
    tl.exit(code);
})
.fail(function (err) {
    console.error(err.message);
    tl.debug('taskRunner fail');
    tl.exit(1);
})

我想知道如何获得实际值,而不仅仅是 *******,如输出所示:

C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\default\tasks\TestKeyVaultSecretManager[=12=].1.10\KeyVaultSecretManager.exe https://management.core.windows.net/ string ******** ******** {parameters:{ servicePrincipalId: ********, servicePrincipalKey: ********, tenantId: ********}, scheme: ServicePrincipal}
Testing KeyVault https://management.core.windows.net/ string ******** ******** {parameters:{ servicePrincipalId: ********, servicePrincipalKey: ********, tenantId: ********}, scheme: ServicePrincipal}

答案是他们实际上以一种很好的方式实现了这一点,我被愚弄了。

敏感数据隐藏在之后的日志中。因此实际传递到我的控制台应用程序的值获得了正确的值,但是当我再次写入日志时它们又被隐藏了。

输入参数字符串的小操作和打印表明了这一点。