//Import the task lib 0.9.7
import tl = require('vsts-task-lib/task');
//Get the endpoint ID (a guid)
serverEndpoint = tl.getInput('serverEndpoint', true);
//Get the enpoint URL for the retrieved end point id and parse it to URL type
serverEndpointUrl: url.Url = url.parse(tl.getEndpointUrl(this.serverEndpoint, false));
//Extract authentication details from url
serverEndpointAuth = tl.getEndpointAuthorization(this.serverEndpoint, false);
//Read parameters to variable
//NOTE: You cant write this data to console, if you do write, it will write //asterisk (****) instead of real values.
username = this.serverEndpointAuth['parameters']['username'];
password = this.serverEndpointAuth['parameters']['password'];
//Pass the variables as parameters.
2 回答
您需要将要使用的服务 endpoints 添加到构建扩展的task.json中,然后可以在构建任务中使用它 . 有关详细信息,请参阅此链接:Service Endpoints in Team Services .
您还可以查看GitHub中的VSTS Agent Task,了解如何在构建任务(如this one)中使用服务 endpoints .
谢谢艾迪,
我在你的帮助下找到了一个解决方案,我使用了0.5.8版本的vsts-task-lib库并将其更新为0.9.7并执行了以下操作,