How to use the azure-pipelines-tool-lib/tool.cacheFile 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 jfrog / artifactory-vsts-extension / tasks / ArtifactoryNuget / nugetBuild.js View on Github external
let downloadAndRunNuget = async(function (cliPath, nugetCommand) {
    console.log("NuGet not found in Path. Downloading...");
    let downloadPath = await(toolLib.downloadTool("https://dist.nuget.org/win-x86-commandline/v" + NUGET_VERSION + "/nuget.exe"));
    toolLib.cacheFile(downloadPath, NUGET_EXE_FILENAME, NUGET_TOOL_NAME, NUGET_VERSION);
    addToPathAndExec(cliPath, nugetCommand, NUGET_VERSION);
});
github jfrog / artifactory-vsts-extension / artifactory-tasks-utils / utils.js View on Github external
localTools.downloadTool(cliDownloadUrl, null, cliAuthHandlers).then((downloadPath) => {
            toolLib.cacheFile(downloadPath, fileName, toolName, jfrogCliVersion).then((cliDir) => {
                let cliPath = path.join(cliDir, fileName);
                if (!isWindows()) {
                    fs.chmodSync(cliPath, 0o555);
                }
                tl.debug("Finished downloading JFrog cli.");
                resolve(cliPath);
            })
        }).catch((err) => {
            reject(err);
github microsoft / azure-pipelines-tasks / Tasks / DuffleInstallerV0 / src / duffleinstaller.ts View on Github external
async function downloadDuffle(version: string): Promise {
    let cachedToolPath = toolLib.findLocalTool(DuffleToolName, version);
    if (!cachedToolPath) {
        let duffleDownloadPath = '';
        try {
            duffleDownloadPath = getDuffleInstallPath();
            const downloadUrl = getDuffleDownloadURL(version);
            await download(downloadUrl, duffleDownloadPath, false, true);
        } catch (exception) {
            throw new Error(tl.loc('DownloadDuffleFailed', getDuffleDownloadURL(version), exception));
        }

        cachedToolPath = await toolLib.cacheFile(duffleDownloadPath, DuffleToolName + getExecutableExtension(), DuffleToolName, version);
    }

    const dufflePath = path.join(cachedToolPath, DuffleToolName + getExecutableExtension());
    fs.chmod(dufflePath, '777');
    return dufflePath;
}
github microsoft / azure-pipelines-tasks / Tasks / DockerInstallerV0 / src / utils.ts View on Github external
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;
}