本文整理汇总了TypeScript中azure-pipelines-task-lib/task.getEndpointUrl函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getEndpointUrl函数的具体用法?TypeScript getEndpointUrl怎么用?TypeScript getEndpointUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getEndpointUrl函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}, []);
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:8,代码来源:nugetcommandmain.ts
示例2: createOptimizelyClientInstance
public createOptimizelyClientInstance(): OptimizelyXClient {
let endpointId: string = this.taskInputs.getEndpointId();
let endpointUrl: string = tl.getEndpointUrl(endpointId, false);
let pat: string = tl.getEndpointAuthorizationParameter(endpointId, 'apitoken', false);
let oxClient = new OptimizelyXClient(endpointUrl, pat);
return oxClient;
}
开发者ID:Microsoft,项目名称:vsts-rm-extensions,代码行数:7,代码来源:TaskOperation.ts
示例3: 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;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:51,代码来源:authentication.ts
示例4: getInternalAuthInfoArray
export async function getInternalAuthInfoArray(inputKey: string): Promise<AuthInfo[]> {
let internalAuthArray: AuthInfo[] = [];
const feedList = tl.getDelimitedInput(inputKey, ",");
if (!feedList || feedList.length === 0)
{
return internalAuthArray;
}
const serverType = tl.getVariable("System.ServerType");
if (!serverType || serverType.toLowerCase() !== "hosted"){
throw new Error(tl.loc("Error_PythonInternalFeedsNotSupportedOnprem"));
}
tl.debug(tl.loc("Info_AddingInternalFeeds", feedList.length));
let packagingLocation: string;
const serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
const localAccessToken = pkgLocationUtils.getSystemAccessToken();
try {
// This call is to get the packaging URI(abc.pkgs.vs.com) which is same for all protocols.
packagingLocation = await pkgLocationUtils.getNuGetUriFromBaseServiceUri(
serviceUri,
localAccessToken);
} catch (error) {
tl.debug(tl.loc("FailedToGetPackagingUri"));
tl.debug(JSON.stringify(error));
packagingLocation = serviceUri;
}
internalAuthArray = await Promise.all(feedList.map(async (feedName: string) => {
const feedUri = await pkgLocationUtils.getFeedRegistryUrl(
packagingLocation,
pkgLocationUtils.RegistryType.PyPiUpload,
feedName,
null,
localAccessToken,
true /* useSession */);
return new AuthInfo({
feedName,
feedUri,
isInternalSource: true,
} as IPackageSource,
AuthType.Token,
"build",
localAccessToken,
);
}));
return internalAuthArray;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:49,代码来源:authentication.ts
示例5: _logNugetStartupVariables
function _logNugetStartupVariables(nuGetPath: string, nugetVersion: string) {
try {
const nugetfeedtype = tl.getInput("nugetfeedtype");
let externalendpoint = null;
if (nugetfeedtype != null && nugetfeedtype === "external") {
const epId = tl.getInput("externalendpoint");
if (epId) {
externalendpoint = {
feedName: tl.getEndpointUrl(epId, false).replace(/\W/g, ""),
feedUri: tl.getEndpointUrl(epId, false),
};
}
}
let externalendpoints = tl.getDelimitedInput("externalendpoints", ",");
if (externalendpoints) {
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;
}, []);
}
const nugetTelem = {
"command": tl.getInput("command"),
"NUGET_EXE_TOOL_PATH_ENV_VAR": tl.getVariable(nuGetGetter.NUGET_EXE_TOOL_PATH_ENV_VAR),
"NUGET_EXE_CUSTOM_LOCATION": tl.getVariable(NUGET_EXE_CUSTOM_LOCATION),
"searchPatternPack": tl.getPathInput("searchPatternPack"),
"configurationToPack": tl.getInput("configurationToPack"),
"versioningScheme": tl.getInput("versioningScheme"),
"includeReferencedProjects": tl.getBoolInput("includeReferencedProjects"),
"versionEnvVar": tl.getInput("versioningScheme") === "byEnvVar" ?
tl.getVariable(tl.getInput("versionEnvVar")) : null,
"requestedMajorVersion": tl.getInput("requestedMajorVersion"),
"requestedMinorVersion": tl.getInput("requestedMinorVersion"),
"requestedPatchVersion": tl.getInput("requestedPatchVersion"),
"packTimezone": tl.getInput("packTimezone"),
"buildProperties": tl.getInput("buildProperties"),
"basePath": tl.getInput("basePath"),
"verbosityPack": tl.getInput("verbosityPack"),
"includeSymbols": tl.getBoolInput("includeSymbols"),
"NuGet.UseLegacyFindFiles": tl.getVariable("NuGet.UseLegacyFindFiles"),
"NuGetTasks.IsHostedTestEnvironment": tl.getVariable("NuGetTasks.IsHostedTestEnvironment"),
"System.TeamFoundationCollectionUri": tl.getVariable("System.TeamFoundationCollectionUri"),
"NuGet.OverwritePackagingCollectionUrl": tl.getVariable("NuGet.OverwritePackagingCollectionUrl"),
"externalendpoint": externalendpoint,
"externalendpoints": externalendpoints,
"allowpackageconflicts": tl.getInput("allowpackageconflicts"),
"includenugetorg": tl.getInput("includenugetorg"),
"nocache": tl.getInput("nocache"),
"disableparallelprocessing": tl.getInput("disableParallelProcessing"),
"nugetconfigpath": tl.getInput("nugetconfigpath"),
"nugetfeedtype": nugetfeedtype,
"searchpatternpush": tl.getInput("searchpatternpush"),
"selectorconfig": tl.getInput("selectorconfig"),
"solution": tl.getInput("solution"),
"verbositypush": tl.getInput("verbositypush"),
"verbosityrestore": tl.getInput("verbosityrestore"),
"nuGetPath": nuGetPath,
"nugetVersion": nugetVersion,
};
telemetry.emitTelemetry("Packaging", "NuGetCommand", nugetTelem);
} catch (err) {
tl.debug(`Unable to log NuGet task init telemetry. Err:( ${err} )`);
}
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:69,代码来源:nugetcommandmain.ts
示例6: FromServiceEndpoint
public static async FromServiceEndpoint(endpointId: string, authOnly?: boolean): Promise<NpmRegistry> {
const lineEnd = os.EOL;
let endpointAuth: tl.EndpointAuthorization;
let url: string;
let nerfed: string;
let auth: string;
let username: string;
let password: string;
let email: string;
let password64: string;
let isVstsTokenAuth: boolean = false;
try {
endpointAuth = tl.getEndpointAuthorization(endpointId, false);
} catch (exception) {
throw new Error(tl.loc('ServiceEndpointNotDefined'));
}
try {
url = NormalizeRegistry(tl.getEndpointUrl(endpointId, false));
// To the reader, this could be optimized here but it is broken out for readability
if (endpointAuth.scheme === 'Token') {
isVstsTokenAuth = await NpmRegistry.isEndpointInternal(url);
}
nerfed = util.toNerfDart(url);
} catch (exception) {
throw new Error(tl.loc('ServiceEndpointUrlNotDefined'));
}
switch (endpointAuth.scheme) {
case 'UsernamePassword':
username = endpointAuth.parameters['username'];
password = endpointAuth.parameters['password'];
email = username; // npm needs an email to be set in order to publish, this is ignored on npmjs
password64 = (new Buffer(password).toString('base64'));
tl.setSecret(password64);
auth = nerfed + ':username=' + username + lineEnd;
auth += nerfed + ':_password=' + password64 + lineEnd;
auth += nerfed + ':email=' + email + lineEnd;
break;
case 'Token':
const apitoken = endpointAuth.parameters['apitoken'];
if (!isVstsTokenAuth){
// Use Bearer auth as it was intended.
auth = nerfed + ':_authToken=' + apitoken + lineEnd;
} else {
// Azure DevOps does not support PATs+Bearer only JWTs+Bearer
email = 'VssEmail';
username = 'VssToken';
password64 = (new Buffer(apitoken).toString('base64'));
tl.setSecret(password64);
auth = nerfed + ':username=' + username + lineEnd;
auth += nerfed + ':_password=' + password64 + lineEnd;
auth += nerfed + ':email=' + email + lineEnd;
}
break;
}
auth += nerfed + ':always-auth=true';
return new NpmRegistry(url, auth, authOnly);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:63,代码来源:npmregistry.ts
示例7: main
async function main(): Promise<void> {
let packagingLocation: pkgLocationUtils.PackagingLocation;
try {
packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet);
} catch (error) {
tl.debug("Unable to get packaging URIs, using default collection URI");
tl.debug(JSON.stringify(error));
const collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri");
packagingLocation = {
PackagingUris: [collectionUrl],
DefaultPackagingUri: collectionUrl};
}
tl.setResourcePath(path.join(__dirname, "task.json"));
let buildIdentityDisplayName: string = null;
let buildIdentityAccount: string = null;
let command: string = tl.getInput("command", true);
let args: string = tl.getInput("arguments", false);
// Getting NuGet
tl.debug('Getting NuGet');
let nuGetPath: string = undefined;
try {
nuGetPath = process.env[nuGetGetter.NUGET_EXE_TOOL_PATH_ENV_VAR];
if (!nuGetPath){
nuGetPath = await nuGetGetter.getNuGet("4.0.0");
}
}
catch (error) {
tl.setResult(tl.TaskResult.Failed, error.message);
return;
}
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 {
nutil.setConsoleCodePage();
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 = pkgLocationUtils.getSystemAccessToken();
let serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
let urlPrefixes = packagingLocation.PackagingUris;
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}`);
}
const authInfo = new auth.NuGetAuthInfo(urlPrefixes, accessToken);
let environmentSettings: ngToolRunner.NuGetEnvironmentSettings = {
authInfo: authInfo,
credProviderFolder: useCredProvider ? path.dirname(credProviderPath) : null,
extensionsDisabled: true
};
let executionOptions = new NuGetExecutionOptions(
nuGetPath,
environmentSettings,
command,
args);
await runNuGetAsync(executionOptions);
} catch (err) {
tl.error(err);
if (buildIdentityDisplayName || buildIdentityAccount) {
tl.warning(tl.loc("BuildIdentityPermissionsHint", buildIdentityDisplayName, buildIdentityAccount));
}
tl.setResult(tl.TaskResult.Failed, "");
}
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:90,代码来源:nuget.ts
示例8: main
//.........这里部分代码省略.........
versionToUse = "4.0.0";
}
else if (nugetUxOption === "3.5.0.1829") {
nuGetPathSuffix = "NuGet/3.5.0/";
versionToUse = "3.5.0";
}
else if (nugetUxOption === "3.3.0") {
nuGetPathSuffix = "NuGet/3.3.0/";
versionToUse = "3.3.0";
}
else {
throw new Error(tl.loc("NGCommon_UnabletoDetectNuGetVersion"));
}
// save and reset the tool path env var, so this task doesn't act as a tool installer
const tempNuGetPath = tl.getVariable(ngToolGetter.NUGET_EXE_TOOL_PATH_ENV_VAR);
const cachedVersion = await ngToolGetter.cacheBundledNuGet(versionToUse, nuGetPathSuffix);
nuGetPath = await ngToolGetter.getNuGet(cachedVersion);
tl.setVariable(ngToolGetter.NUGET_EXE_TOOL_PATH_ENV_VAR, tempNuGetPath);
}
//find nuget location to use
let credProviderPath = nutil.locateCredentialProvider();
const quirks = await ngToolRunner.getNuGetQuirksAsync(nuGetPath);
// clauses ordered in this way to avoid short-circuit evaluation, so the debug info printed by the functions
// is unconditionally displayed
const useCredProvider = ngToolRunner.isCredentialProviderEnabled(quirks) && credProviderPath;
const useCredConfig = ngToolRunner.isCredentialConfigEnabled(quirks) && !useCredProvider;
let accessToken = pkgLocationUtils.getSystemAccessToken();
let urlPrefixes = packagingLocation.PackagingUris;
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}`);
}
const authInfo = new auth.NuGetAuthInfo(urlPrefixes, accessToken);
let environmentSettings: ngToolRunner.NuGetEnvironmentSettings = {
authInfo: authInfo,
credProviderFolder: useCredProvider ? path.dirname(credProviderPath) : null,
extensionsDisabled: !userNuGetProvided
}
let configFile = null;
let apiKey: string;
let feedUri: string;
let credCleanup = () => { return };
if (nuGetFeedType == "internal") {
if (useCredConfig) {
let nuGetConfigHelper = new NuGetConfigHelper(nuGetPath, null, authInfo, environmentSettings);
nuGetConfigHelper.setSources([{ feedName: "internalFeed", feedUri: internalFeedUri }], true);
configFile = nuGetConfigHelper.tempNugetConfigPath;
credCleanup = () => tl.rmRF(nuGetConfigHelper.tempNugetConfigPath);
}
apiKey = "VSTS";
feedUri = internalFeedUri;
}
else {
feedUri = tl.getEndpointUrl(connectedServiceName, false);
let externalAuth = tl.getEndpointAuthorization(connectedServiceName, false);
apiKey = externalAuth.parameters["password"];
}
try {
let publishOptions = new PublishOptions(
nuGetPath,
feedUri,
apiKey,
configFile,
verbosity,
nuGetAdditionalArgs,
environmentSettings);
for (const packageFile of filesList) {
await publishPackageAsync(packageFile, publishOptions);
}
} finally {
credCleanup();
}
tl.setResult(tl.TaskResult.Succeeded, tl.loc("PackagesPublishedSuccessfully"));
} catch (err) {
tl.error(err);
if (buildIdentityDisplayName || buildIdentityAccount) {
tl.warning(tl.loc("BuildIdentityPermissionsHint", buildIdentityDisplayName, buildIdentityAccount));
}
tl.setResult(tl.TaskResult.Failed, tl.loc("PackagesFailedToPublish"));
}
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:101,代码来源:nugetpublisher.ts
注:本文中的azure-pipelines-task-lib/task.getEndpointUrl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论