本文整理汇总了TypeScript中vsts-task-tool-lib/tool.downloadTool函数的典型用法代码示例。如果您正苦于以下问题:TypeScript downloadTool函数的具体用法?TypeScript downloadTool怎么用?TypeScript downloadTool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了downloadTool函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: acquireNodeFromFallbackLocation
// For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
// In this case, there will be two files located at:
// /dist/v5.10.1/win-x64/node.exe
// /dist/v5.10.1/win-x64/node.lib
// If this is not the structure, there may also be two files located at:
// /dist/v0.12.18/node.exe
// /dist/v0.12.18/node.lib
// This method attempts to download and cache the resources from these alternative locations.
// Note also that the files are normally zipped but in this case they are just an exe
// and lib file in a folder, not zipped.
async function acquireNodeFromFallbackLocation(version: string): Promise<string> {
// Create temporary folder to download in to
let tempDownloadFolder: string = 'temp_' + Math.floor(Math.random() * 2000000000);
let tempDir: string = path.join(taskLib.getVariable('agent.tempDirectory'), tempDownloadFolder);
taskLib.mkdirP(tempDir);
let exeUrl: string;
let libUrl: string;
try {
exeUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
libUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;
await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
}
catch (err) {
if (err['httpStatusCode'] &&
err['httpStatusCode'] === '404')
{
exeUrl = `https://nodejs.org/dist/v${version}/node.exe`;
libUrl = `https://nodejs.org/dist/v${version}/node.lib`;
await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
}
else {
throw err;
}
}
return await toolLib.cacheDir(tempDir, 'node', version);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:42,代码来源:installer.ts
示例2: acquireNodeFromFallbackLocation
// For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
// In this case, there will be two files located at:
// /dist/v5.10.1/win-x64/node.exe
// /dist/v5.10.1/win-x64/node.lib
// This method attempts to download and cache the resources from this alternative location.
// Note also that the files are normally zipped but in this case they are just an exe
// and lib file in a folder, not zipped.
async function acquireNodeFromFallbackLocation(version: string): Promise<string> {
let exeUrl: string = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
let libUrl: string = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;
// Create temporary folder to download in to
let tempDownloadFolder: string = 'temp_' + Math.floor(Math.random() * 2000000000);
let tempDir: string = path.join(taskLib.getVariable('agent.tempDirectory'), tempDownloadFolder);
taskLib.mkdirP(tempDir);
let exeDownloadPath: string = await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
let libDownloadPath: string = await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
return await toolLib.cacheDir(tempDir, 'node', version);
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:23,代码来源:nodetool.ts
示例3: downloadAndInstall
private async downloadAndInstall(downloadUrls: string[]) {
let downloaded = false;
let downloadPath = "";
for (const url of downloadUrls) {
try {
downloadPath = await toolLib.downloadTool(url);
downloaded = true;
break;
} catch (error) {
tl.warning(tl.loc("CouldNotDownload", url, JSON.stringify(error)));
}
}
if (!downloaded) {
throw tl.loc("FailedToDownloadPackage");
}
// extract
console.log(tl.loc("ExtractingPackage", downloadPath));
let extPath: string = tl.osType().match(/^Win/) ? await toolLib.extractZip(downloadPath) : await toolLib.extractTar(downloadPath);
// cache tool
console.log(tl.loc("CachingTool"));
let cachedDir = await toolLib.cacheDir(extPath, this.cachedToolName, this.version);
console.log(tl.loc("SuccessfullyInstalled", this.packageType, this.version));
return cachedDir;
}
开发者ID:grawcho,项目名称:vso-agent-tasks,代码行数:27,代码来源:dotnetcoreinstaller.ts
示例4: downloadAndInstall
public async downloadAndInstall(versionInfo: VersionInfo, downloadUrl: string): Promise<void> {
if (!versionInfo || !versionInfo.getVersion() || !downloadUrl || !url.parse(downloadUrl)) {
throw tl.loc("VersionCanNotBeDownloadedFromUrl", versionInfo, downloadUrl);
}
let version = versionInfo.getVersion();
try {
try {
var downloadPath = await toolLib.downloadTool(downloadUrl)
}
catch (ex) {
throw tl.loc("CouldNotDownload", downloadUrl, ex);
}
// Extract
console.log(tl.loc("ExtractingPackage", downloadPath));
try {
var extPath = tl.osType().match(/^Win/) ? await toolLib.extractZip(downloadPath) : await toolLib.extractTar(downloadPath);
}
catch (ex) {
throw tl.loc("FailedWhileExtractingPacakge", ex);
}
// Copy folders
tl.debug(tl.loc("CopyingFoldersIntoPath", this.installationPath));
var allRootLevelEnteriesInDir: string[] = tl.ls("", [extPath]).map(name => path.join(extPath, name));
var directoriesTobeCopied: string[] = allRootLevelEnteriesInDir.filter(path => fs.lstatSync(path).isDirectory());
directoriesTobeCopied.forEach((directoryPath) => {
tl.cp(directoryPath, this.installationPath, "-rf", false);
});
// Copy files
try {
if (this.packageType == utils.Constants.sdk && this.isLatestInstalledVersion(version)) {
tl.debug(tl.loc("CopyingFilesIntoPath", this.installationPath));
var filesToBeCopied = allRootLevelEnteriesInDir.filter(path => !fs.lstatSync(path).isDirectory());
filesToBeCopied.forEach((filePath) => {
tl.cp(filePath, this.installationPath, "-f", false);
});
}
}
catch (ex) {
tl.warning(tl.loc("FailedToCopyTopLevelFiles", this.installationPath, ex));
}
// Cache tool
this.createInstallationCompleteFile(versionInfo);
console.log(tl.loc("SuccessfullyInstalled", this.packageType, version));
}
catch (ex) {
throw tl.loc("FailedWhileInstallingVersionAtPath", version, this.installationPath, ex);
}
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:55,代码来源:versioninstaller.ts
示例5: acquireDotNetCore
async function acquireDotNetCore(packageType: string, version: string): Promise<string> {
let downloadUrls = getDownloadUrls(packageType, version);
let downloadPath: string;
try {
// try primary url
if (!!downloadUrls[0]) {
console.log(taskLib.loc("DownloadingPrimaryUrl", downloadUrls[0]));
downloadPath = await toolLib.downloadTool(downloadUrls[0]);
}
} catch (error1) {
console.log(taskLib.loc("PrimaryUrlDownloadFailed", error1));
try {
// try secondary url
if (!!downloadUrls[1]) {
console.log(taskLib.loc("DownloadingSecondaryUrl", downloadUrls[1]));
downloadPath = await toolLib.downloadTool(downloadUrls[1]);
}
} catch (error2) {
console.log(taskLib.loc("LegacyUrlDownloadFailed", error2));
throw taskLib.loc("DownloadFailed", packageType, version);
}
}
// extract
let extPath: string;
console.log(taskLib.loc("ExtractingPackage", downloadPath));
if (taskLib.osType().match(/^Win/)) {
extPath = await toolLib.extractZip(downloadPath);
}
else {
extPath = await toolLib.extractTar(downloadPath);
}
// cache tool
let cachedToolName = getCachedToolName(packageType);
console.log(taskLib.loc("CachingTool"));
let cachedDir = await toolLib.cacheDir(extPath, cachedToolName, version);
console.log(taskLib.loc("SuccessfullyInstalled", packageType, version));
return cachedDir;
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:41,代码来源:dotnetcoreinstaller.ts
示例6: acquireNode
async function acquireNode(version: string): Promise<string> {
//
// Download - a tool installer intimately knows how to get the tool (and construct urls)
//
version = toolLib.cleanVersion(version);
let fileName: string = osPlat == 'win32'? 'node-v' + version + '-win-' + os.arch() :
'node-v' + version + '-' + osPlat + '-' + os.arch();
let urlFileName: string = osPlat == 'win32'? fileName + '.7z':
fileName + '.tar.gz';
let downloadUrl = 'https://nodejs.org/dist/v' + version + '/' + urlFileName;
let downloadPath: string;
try
{
downloadPath = await toolLib.downloadTool(downloadUrl);
}
catch (err)
{
if (err['httpStatusCode'] &&
err['httpStatusCode'] == '404')
{
return await acquireNodeFromFallbackLocation(version);
}
throw err;
}
//
// Extract
//
let extPath: string;
if (osPlat == 'win32') {
taskLib.assertAgent('2.115.0');
extPath = taskLib.getVariable('Agent.TempDirectory');
if (!extPath) {
throw new Error('Expected Agent.TempDirectory to be set');
}
extPath = path.join(extPath, 'n'); // use as short a path as possible due to nested node_modules folders
extPath = await toolLib.extract7z(downloadPath, extPath);
}
else {
extPath = await toolLib.extractTar(downloadPath);
}
//
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
//
let toolRoot = path.join(extPath, fileName);
return await toolLib.cacheDir(toolRoot, 'node', version);
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:53,代码来源:nodetool.ts
示例7: getArtifactToolFromService
export async function getArtifactToolFromService(serviceUri: string, accessToken: string, toolName: string){
let osName = tl.osType();
let arch = os.arch();
if(osName === "Windows_NT"){
osName = "windows";
}
if (arch === "x64"){
arch = "amd64";
}
const blobstoreAreaName = "clienttools";
const blobstoreAreaId = "187ec90d-dd1e-4ec6-8c57-937d979261e5";
const ApiVersion = "5.0-preview";
const blobstoreConnection = getWebApiWithProxy(serviceUri, accessToken);
try{
const artifactToolGetUrl = await blobstoreConnection.vsoClient.getVersioningData(ApiVersion,
blobstoreAreaName, blobstoreAreaId, { toolName }, {osName, arch});
const artifactToolUri = await blobstoreConnection.rest.get(artifactToolGetUrl.requestUrl);
if (artifactToolUri.statusCode !== 200){
tl.debug(tl.loc("Error_UnexpectedErrorFailedToGetToolMetadata", artifactToolUri.toString()));
throw new Error(tl.loc("Error_UnexpectedErrorFailedToGetToolMetadata", artifactToolGetUrl.requestUrl));
}
let artifactToolPath = toollib.findLocalTool(toolName, artifactToolUri.result.version);
if (!artifactToolPath) {
tl.debug(tl.loc("Info_DownloadingArtifactTool", artifactToolUri.result.uri));
const zippedToolsDir: string = await toollib.downloadTool(artifactToolUri.result.uri);
tl.debug("Downloaded zipped artifact tool to " + zippedToolsDir);
const unzippedToolsDir = await extractZip(zippedToolsDir);
artifactToolPath = await toollib.cacheDir(unzippedToolsDir, "ArtifactTool", artifactToolUri.result.version);
}
else{
tl.debug(tl.loc("Info_ResolvedToolFromCache", artifactToolPath));
}
return getArtifactToolLocation(artifactToolPath);
}
catch(err){
tl.error(err);
tl.setResult(tl.TaskResult.Failed, tl.loc("FailedToGetArtifactTool", err));
}
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:49,代码来源:ArtifactToolUtilities.ts
示例8: downloadKubectl
export async function downloadKubectl(version: string) : Promise<string> {
var cachedToolpath = toolLib.findLocalTool(kubectlToolName, version);
if(!cachedToolpath) {
try {
var KubectlDownloadPath = await toolLib.downloadTool(getkubectlDownloadURL(version));
} catch(exception) {
throw new Error(tl.loc("DownloadKubectlFailedFromLocation", getkubectlDownloadURL(version), exception));
}
cachedToolpath = await toolLib.cacheFile(KubectlDownloadPath, kubectlToolName + getExecutableExtention() , kubectlToolName, version);
}
var kubectlPath = path.join(cachedToolpath, kubectlToolName + getExecutableExtention());
fs.chmodSync(kubectlPath, "777");
return kubectlPath;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:16,代码来源:kubectlutility.ts
示例9: acquireGo
async function acquireGo(version: string): Promise<string> {
//
// Download - a tool installer intimately knows how to get the tool (and construct urls)
//
let fileName: string = getFileName(version);
let downloadUrl: string = getDownloadUrl(fileName);
let downloadPath: string = null;
try {
downloadPath = await toolLib.downloadTool(downloadUrl);
} catch (error) {
tl.debug(error);
// cannot localized the string here because to localize we need to set the resource file.
// which can be set only once. vsts-task-tool-lib/tool, is already setting it to different file.
// So left with no option but to hardcode the string. Other tasks are doing the same.
throw (util.format("Failed to download version %s. Please verify that the version is valid and resolve any other issues. %s", version, error));
}
//make sure agent version is latest then 2.115.0
tl.assertAgent('2.115.0');
//
// Extract
//
let extPath: string;
extPath = tl.getVariable('Agent.TempDirectory');
if (!extPath) {
throw new Error("Expected Agent.TempDirectory to be set");
}
if (osPlat == 'win32') {
extPath = await toolLib.extractZip(downloadPath);
}
else {
extPath = await toolLib.extractTar(downloadPath);
}
//
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
//
let toolRoot = path.join(extPath, "go");
version = fixVersion(version);
return await toolLib.cacheDir(toolRoot, 'go', version);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:44,代码来源:gotool.ts
示例10: downloadHelm
export async function downloadHelm(version?: string): Promise<string> {
if (!version) version = await getStableHelmVersion();
var cachedToolpath = toolLib.findLocalTool(helmToolName, version);
if (!cachedToolpath) {
try {
var helmDownloadPath = await toolLib.downloadTool(getHelmDownloadURL(version), helmToolName + "-" + version + "-" + uuidV4() + ".zip");
} catch (exception) {
throw new Error(tl.loc("HelmDownloadFailed", getHelmDownloadURL(version), exception));
}
var unzipedHelmPath = await toolLib.extractZip(helmDownloadPath);
cachedToolpath = await toolLib.cacheDir(unzipedHelmPath, helmToolName, version);
}
var helmpath = findHelm(cachedToolpath);
if (!helmpath) {
throw new Error(tl.loc("HelmNotFoundInFolder", cachedToolpath))
}
fs.chmodSync(helmpath, "777");
return helmpath;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:21,代码来源:helmutility.ts
注:本文中的vsts-task-tool-lib/tool.downloadTool函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论