How to use the azure-pipelines-tool-lib/tool.extractZip 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 / UseGoV1 / installer.ts View on Github external
throw (util.format(tl.loc('FailedToDownload'), version, error));
    }

    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
}

    //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);
}
github rdagumampan / yuniql / yuniql-azure-pipelines / src / install / installer.ts View on Github external
let packageFileName: string = '';
            switch (osPlat) {
                case 'win32': packageFileName = 'yuniql-cli-win-' + osArch + '-' + version + '.zip'; break;
                //case 'linux': dataFileName = 'yuniql-cli-linux-' + osArch + '-' + version + '.tar'; break;
                default: throw new Error(`Unsupported Agent OS '${osPlat}'`);
            }

            const downloadBaseUrl = 'https://github.com/rdagumampan/yuniql/releases/download'
            const downloadUrl = downloadBaseUrl + '/' + version + '/' + packageFileName;
            console.log('yuniql/var_downloadUrl: ' + downloadUrl);

            const temp: string = await toolLib.downloadTool(downloadUrl);
            console.log('yuniql/var_temp: ' + temp);

            //extract assemblies
            const extractRoot: string = await toolLib.extractZip(temp);
            console.log('yuniql/var_extractRoot: ' + extractRoot);

            //cache assemblies
            if (version != 'latest') {
                toolLib.cacheDir(extractRoot, "yuniql", version);
            } else {
                //use v0.0.0 as placeholder for latest version
                //TODO: always replace the current cached version for now
                toolLib.cleanVersion('v0.0.0');
                toolLib.cacheDir(extractRoot, "yuniql", 'v0.0.0');
            }

            //append PATH
            toolLib.prependPath(extractRoot);
        }
    }
github microsoft / azure-pipelines-tasks / Tasks / Common / func-tools-common / functoolsutility.ts View on Github external
export async function downloadFuncTools(version: string): Promise {
        let cachedToolpath = toolLib.findLocalTool(funcToolName, version);
        
        if (!cachedToolpath) {
            const downloadUrl = getDownloadUrl(version);
            let downloadPath;
            try {
                downloadPath = await toolLib.downloadTool(downloadUrl);
            }
            catch (ex) {
                throw new Error(tl.loc('FuncDownloadFailed', downloadUrl, ex));
            }
            
            tl.debug('Extracting the downloaded func tool zip..');
            const unzippedFuncPath = await toolLib.extractZip(downloadPath);
            cachedToolpath = await toolLib.cacheDir(unzippedFuncPath, funcToolName, version);
            console.log(tl.loc("SuccessfullyDownloaded", version, cachedToolpath));
        } else {
            console.log(tl.loc("VersionAlreadyInstalled", version, cachedToolpath));
        }

        const funcPath = path.join(cachedToolpath, funcToolName + getExecutableExtension());
        fs.chmodSync(funcPath, '777');
        return funcPath;
}
github microsoft / azure-pipelines-tasks / Tasks / DockerInstallerV0 / src / utils.ts View on Github external
export async function downloadDocker(version: string, releaseType: string): Promise {
   
    //docker does not follow strict semversion and has leading zeros in versions <10
    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");