本文整理汇总了TypeScript中vsts-task-lib/task.getEndpointUrl函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getEndpointUrl函数的具体用法?TypeScript getEndpointUrl怎么用?TypeScript getEndpointUrl使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getEndpointUrl函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
externalendpoints = externalendpoints.reduce((ary, id) => {
const te = {
feedName: tl.getEndpointUrl(id, false).replace(/\W/g, ""),
feedUri: tl.getEndpointUrl(id, false),
};
ary.push(te);
return ary;
}, []);
示例2: setConnectionDetails
private static setConnectionDetails(inputs: UserInputs) {
var endpoint: string = tl.getInput("NAC", true);
var credentials = tl.getEndpointAuthorization(endpoint, false)["parameters"];
inputs.url = tl.getEndpointUrl(endpoint, false);
inputs.userName = credentials[RAConstants.USER_NAME];
inputs.password = credentials[RAConstants.PASSWORD];
};
示例3: run
export async function run(nuGetPath: string): Promise<void> {
nutil.setConsoleCodePage();
let buildIdentityDisplayName: string = null;
let buildIdentityAccount: string = null;
let args: string = tl.getInput("arguments", false);
const version = await peParser.getFileVersionInfoAsync(nuGetPath);
if(version.productVersion.a < 3 || (version.productVersion.a <= 3 && version.productVersion.b < 5))
{
tl.setResult(tl.TaskResult.Failed, tl.loc("Info_NuGetSupportedAfter3_5", version.strings.ProductVersion));
return;
}
try {
let credProviderPath = nutil.locateCredentialProvider();
// Clauses ordered in this way to avoid short-circuit evaluation, so the debug info printed by the functions
// is unconditionally displayed
const quirks = await ngToolRunner.getNuGetQuirksAsync(nuGetPath);
const useCredProvider = ngToolRunner.isCredentialProviderEnabled(quirks) && credProviderPath;
// useCredConfig not placed here: This task will only support NuGet versions >= 3.5.0 which support credProvider both hosted and OnPrem
let accessToken = auth.getSystemAccessToken();
let serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
let urlPrefixes = await locationHelpers.assumeNuGetUriPrefixes(serviceUri);
tl.debug(`Discovered URL prefixes: ${urlPrefixes}`);
// Note to readers: This variable will be going away once we have a fix for the location service for
// customers behind proxies
let testPrefixes = tl.getVariable("NuGetTasks.ExtraUrlPrefixesForTesting");
if (testPrefixes) {
urlPrefixes = urlPrefixes.concat(testPrefixes.split(";"));
tl.debug(`All URL prefixes: ${urlPrefixes}`);
}
let authInfo = new auth.NuGetExtendedAuthInfo(new auth.InternalAuthInfo(urlPrefixes, accessToken, useCredProvider, false), []);
let environmentSettings: ngToolRunner.NuGetEnvironmentSettings = {
credProviderFolder: useCredProvider ? path.dirname(credProviderPath) : null,
extensionsDisabled: true
};
let executionOptions = new NuGetExecutionOptions(
nuGetPath,
environmentSettings,
args,
authInfo);
runNuGet(executionOptions);
} catch (err) {
tl.error(err);
if (buildIdentityDisplayName || buildIdentityAccount) {
tl.warning(tl.loc("BuildIdentityPermissionsHint", buildIdentityDisplayName, buildIdentityAccount));
}
tl.setResult(tl.TaskResult.Failed, "");
}
}
示例4: getOctopusConnectionDetails
export function getOctopusConnectionDetails(name: string): OctoServerConnectionDetails {
const octoEndpointAuthorization = tasks.getEndpointAuthorization(name, false);
const ignoreSSL = tasks.getEndpointDataParameter(name, "ignoreSslErrors", true);
return {
url: tasks.getEndpointUrl(name, false),
apiKey: octoEndpointAuthorization.parameters["apitoken"],
ignoreSslErrors: !!ignoreSSL && ignoreSSL.toLowerCase() === "true"
}
}
示例5: createKubeconfig
export function createKubeconfig(kubernetesServiceEndpoint: string): string
{
var kubeconfigTemplateString = '{"apiVersion":"v1","kind":"Config","clusters":[{"cluster":{"certificate-authority-data": null,"server": null}}], "users":[{"user":{"token": null}}]}';
var kubeconfigTemplate = JSON.parse(kubeconfigTemplateString);
//populate server url, ca cert and token fields
kubeconfigTemplate.clusters[0].cluster.server = tl.getEndpointUrl(kubernetesServiceEndpoint, false);
kubeconfigTemplate.clusters[0].cluster["certificate-authority-data"] = tl.getEndpointAuthorizationParameter(kubernetesServiceEndpoint, 'serviceAccountCertificate', false);
kubeconfigTemplate.users[0].user.token = Base64.decode(tl.getEndpointAuthorizationParameter(kubernetesServiceEndpoint, 'apiToken', false));
return JSON.stringify(kubeconfigTemplate);
}
示例6: run
async function run() {
try {
tl.setResourcePath(path.join( __dirname, 'task.json'));
var connectedServiceName = tl.getInput('ConnectedServiceName', true);
var resourceGroupName: string = tl.getInput("ResourceGroupName", true);
var loadBalancerName: string = tl.getInput("LoadBalancer", true);
var action: string = tl.getInput("Action", true);
var endPointAuthCreds = tl.getEndpointAuthorization(connectedServiceName, true);
var endpointUrl = tl.getEndpointUrl(connectedServiceName, true);
var SPN = new Array();
SPN["servicePrincipalClientID"] = endPointAuthCreds.parameters["serviceprincipalid"];
SPN["servicePrincipalKey"] = endPointAuthCreds.parameters["serviceprincipalkey"];
SPN["tenantID"] = endPointAuthCreds.parameters["tenantid"];
SPN["subscriptionId"] = tl.getEndpointDataParameter(connectedServiceName, 'subscriptionid', true);
SPN["envAuthUrl"] = tl.getEndpointDataParameter(connectedServiceName, 'environmentAuthorityUrl', true);
SPN["url"] = tl.getEndpointUrl(connectedServiceName, true);
var nicVm = await getNetworkInterface(SPN, endpointUrl, resourceGroupName);
tl.debug(`Network Interface - ${nicVm.name}'s configuration details fetched for the virtual machine ${process.env.COMPUTERNAME}`);
var nicLbBackendPoolConfig = null;
if (action == "Connect") {
tl._writeLine(tl.loc("ConnectingVMtoLB", loadBalancerName));
var lb = await nlbUtility.getLoadBalancer(SPN, endpointUrl, loadBalancerName, resourceGroupName);
nicLbBackendPoolConfig = lb.properties.backendAddressPools;
}
else {
tl._writeLine(tl.loc("DisconnectingVMfromLB", loadBalancerName));
}
nicVm.properties.ipConfigurations[0].properties['loadBalancerBackendAddressPools'] = nicLbBackendPoolConfig;
var setNIStatus = await nlbUtility.setNetworkInterface(SPN, endpointUrl, nicVm, resourceGroupName);
tl._writeLine(tl.loc(setNIStatus, nicVm.name));
tl._writeLine(tl.loc("ActionCompletedSuccefully", action, process.env.COMPUTERNAME, loadBalancerName));
}
catch(error) {
tl.setResult(tl.TaskResult.Failed, error);
}
}
示例7: getExternalAuthInfoArray
export async function getExternalAuthInfoArray(inputKey: string): Promise<AuthInfo[]>
{
let externalAuthArray: AuthInfo[] = [];
let endpointNames = tl.getDelimitedInput(inputKey, ",");
if (!endpointNames || endpointNames.length === 0)
{
return externalAuthArray;
}
tl.debug(tl.loc("Info_AddingExternalFeeds", endpointNames.length));
for (let endpointId of endpointNames)
{
let feedUri = tl.getEndpointUrl(endpointId, false);
let endpointName = tl.getEndpointDataParameter(endpointId, "endpointname", false);
let externalAuth = tl.getEndpointAuthorization(endpointId, true);
let scheme = tl.getEndpointAuthorizationScheme(endpointId, true).toLowerCase();
switch(scheme) {
case "token":
const token = externalAuth.parameters["apitoken"];
tl.debug(tl.loc("Info_AddingTokenAuthEntry", feedUri));
externalAuthArray.push(new AuthInfo({
feedName: endpointName,
feedUri,
isInternalSource: false,
} as IPackageSource,
AuthType.Token,
"build", // fake username, could be anything.
token,
));
break;
case "usernamepassword":
let username = externalAuth.parameters["username"];
let password = externalAuth.parameters["password"];
tl.debug(tl.loc("Info_AddingPasswordAuthEntry", feedUri));
externalAuthArray.push(new AuthInfo({
feedName: endpointName,
feedUri,
isInternalSource: false,
} as IPackageSource,
AuthType.UsernamePassword,
username,
password));
break;
case "none":
default:
break;
}
}
return externalAuthArray;
}
示例8: resolve
var promise = new Promise<void>(async (resolve, reject) => {
let connection = tl.getInput("connection", true);
let definitionId = tl.getInput("definition", true);
let buildId = tl.getInput("version", true);
let itemPattern = tl.getInput("itemPattern", false);
let downloadPath = tl.getInput("downloadPath", true);
var endpointUrl = tl.getEndpointUrl(connection, false);
var itemsUrl = `${endpointUrl}/api/v1.1/project/${definitionId}/${buildId}/artifacts`;
itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1");
console.log(tl.loc("DownloadArtifacts", itemsUrl));
var templatePath = path.join(__dirname, 'circleCI.handlebars.txt');
var username = tl.getEndpointAuthorizationParameter(connection, 'username', false);
var circleciVariables = {
"endpoint": {
"url": endpointUrl
}
};
var handler = new webHandlers.BasicCredentialHandler(username, "");
var webProvider = new providers.WebProvider(itemsUrl, templatePath, circleciVariables, handler);
var fileSystemProvider = new providers.FilesystemProvider(downloadPath);
var downloader = new engine.ArtifactEngine();
var downloaderOptions = new engine.ArtifactEngineOptions();
downloaderOptions.itemPattern = itemPattern ? itemPattern : '**';
var debugMode = tl.getVariable('System.Debug');
downloaderOptions.verbose = debugMode ? debugMode.toLowerCase() != 'false' : false;
var parallelLimit : number = +tl.getVariable("release.artifact.download.parallellimit");
if(parallelLimit){
downloaderOptions.parallelProcessingLimit = parallelLimit;
}
await downloader.processItems(webProvider, fileSystemProvider, downloaderOptions).then((result) => {
console.log(tl.loc('ArtifactsSuccessfullyDownloaded', downloadPath));
resolve();
}).catch((error) => {
reject(error);
});
let downloadCommitsFlag: boolean = tl.getBoolInput("downloadCommitsAndWorkItems", true);
if (downloadCommitsFlag) {
var webProviderForDownloaingCommits = new providers.WebProvider(itemsUrl, templatePath, circleciVariables, handler);
downloadCommits(webProviderForDownloaingCommits);
}
});
示例9: resolve
var promise = new Promise<void>(async (resolve, reject) => {
let connection = tl.getInput("connection", true);
let projectId = tl.getInput("project", true);
let definitionId = tl.getInput("definition", true);
let buildId = tl.getInput("version", true);
let itemPattern = tl.getInput("itemPattern", false);
let downloadPath = tl.getInput("downloadPath", true);
var endpointUrl = tl.getEndpointUrl(connection, false);
var itemsUrl = endpointUrl + "/httpAuth/app/rest/builds/id:" + buildId + "/artifacts/children/";
itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1");
console.log(tl.loc("DownloadArtifacts", itemsUrl));
var templatePath = path.join(__dirname, 'teamcity.handlebars');
var username = tl.getEndpointAuthorizationParameter(connection, 'username', false);
var password = tl.getEndpointAuthorizationParameter(connection, 'password', false);
var teamcityVariables = {
"endpoint": {
"url": endpointUrl
}
};
var handler = new webHandlers.BasicCredentialHandler(username, password);
var webProvider = new providers.WebProvider(itemsUrl, templatePath, teamcityVariables, handler);
var fileSystemProvider = new providers.FilesystemProvider(downloadPath);
var parallelLimit : number = +tl.getVariable("release.artifact.download.parallellimit");
var downloader = new engine.ArtifactEngine();
var downloaderOptions = new engine.ArtifactEngineOptions();
downloaderOptions.itemPattern = itemPattern ? itemPattern : '**';
var debugMode = tl.getVariable('System.Debug');
downloaderOptions.verbose = debugMode ? debugMode.toLowerCase() != 'false' : false;
var parallelLimit : number = +tl.getVariable("release.artifact.download.parallellimit");
if(parallelLimit){
downloaderOptions.parallelProcessingLimit = parallelLimit;
}
await downloader.processItems(webProvider, fileSystemProvider, downloaderOptions).then((result) => {
console.log(tl.loc('ArtifactsSuccessfullyDownloaded', downloadPath));
resolve();
}).catch((error) => {
reject(error);
});
});
示例10: GetCommitsFromSingleBuild
private GetCommitsFromSingleBuild(buildId: string): Q.Promise<string> {
let connection = tl.getInput("connection", true);
let definitionId = tl.getInput("definition", true);
var endpointUrl = tl.getEndpointUrl(connection, false);
let defer = Q.defer<string>();
let url: string = `${endpointUrl}/api/v1.1/project/${definitionId}/${buildId}`;
url = url.replace(/([^:]\/)\/+/g, "$1");
this.executeWithRetries("getCommitsFromSingleBuild", (url, headers) => { return this.webProvider.webClient.get(url, headers) }, url, { 'Accept': 'application/json' }).then((res: HttpClientResponse) => {
if (res && res.message.statusCode === 200) {
res.readBody().then((body: string) => {
let jsonResult = JSON.parse(body);
let commits = [];
if (!!jsonResult) {
jsonResult.all_commit_details.forEach(c => {
let commit = {
"Id": c.commit,
"Message": c.subject,
"Author": {
"displayName": c.author_name
},
"DisplayUri": c.commit_url,
"Timestamp": c.author_date
};
commits.push(commit);
});
}
tl.debug("Downloaded " + commits.length + " commits");
defer.resolve(JSON.stringify(commits));
}, (error) => {
defer.reject(error);
});
}
}, (error) => {
defer.reject(error);
});
return defer.promise;
}