How to use the azure-pipelines-tool-lib/tool.extractTar function in azure-pipelines-tool-lib

To help you get started, we’ve selected a few azure-pipelines-tool-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / azure-pipelines-tasks / Tasks / DotNetCoreInstallerV1 / versioninstaller.ts View on Github external
}

        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)) {
github microsoft / azure-pipelines-tasks / Tasks / UseDotNetV2 / versioninstaller.ts View on Github external
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)) {
github microsoft / azure-pipelines-tasks / Tasks / UseGoV1 / installer.ts View on Github external
tl.assertAgent('2.115.0');

    //
    // Extract
    //
    let extPath: string = tl.getVariable('Agent.TempDirectory');
    if (!extPath) {
        throw new Error(tl.loc('TempDirNotSet'));
    }

    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
    //
    const toolRoot = path.join(extPath, "go");
    version = normalizeVersion(version);
    return await toolLib.cacheDir(toolRoot, 'go', version);
}
github microsoft / azure-pipelines-tasks / Tasks / GoToolV0 / gotool.ts View on Github external
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);
}
github microsoft / azure-pipelines-tasks / Tasks / DockerInstallerV0 / src / utils.ts View on Github external
var cleanVersion = version.replace(/(0+)([1-9]+)/,"$2");
    var cachedToolpath = toolLib.findLocalTool(dockerToolName + "-" + releaseType, cleanVersion);
   
    if (!cachedToolpath) {
        try {
            var dockerDownloadPath = await toolLib.downloadTool(getDockerDownloadURL(version, releaseType), dockerToolName + "-" + uuidV4() + getArchiveExtension());
        } catch (exception) {
            throw new Error(tl.loc("DockerDownloadFailed", getDockerDownloadURL(version, releaseType), exception));
        }

        var unzipedDockerPath;
        if(isWindows) {
            unzipedDockerPath = await toolLib.extractZip(dockerDownloadPath);        
        } else {
            //tgz is a tar file packaged using gzip utility
            unzipedDockerPath = await toolLib.extractTar(dockerDownloadPath);
        }

        //contents of the extracted archive are under "docker" directory. caching only "docker(.exe)" CLI
        unzipedDockerPath = path.join(unzipedDockerPath, "docker", dockerToolNameWithExtension);
        cachedToolpath = await toolLib.cacheFile(unzipedDockerPath, dockerToolNameWithExtension, dockerToolName+ "-" + releaseType, cleanVersion);
    }

    var Dockerpath = findDocker(cachedToolpath);
    if (!Dockerpath) {
        throw new Error(tl.loc("DockerNotFoundInFolder", cachedToolpath))
    }

    fs.chmodSync(Dockerpath, "777");
    return Dockerpath;
}