How to use the azure-pipelines-tool-lib/tool.cleanVersion 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-devops-extension-tasks / BuildTasks / TfxInstaller / TfxInstaller.ts View on Github external
async function acquireTfx(version: string): Promise {
    try{
        version = toolLib.cleanVersion(version);
        
        let extPath: string;
        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, 'tfx'); // use as short a path as possible due to nested node_modules folders

        taskLib.mkdirP(path.join(extPath));
        const npmRunner = new tr.ToolRunner("npm");
        npmRunner.arg(["install", "tfx-cli@" + version, "--prefix", extPath]);

        const result = npmRunner.execSync({ failOnStdErr: false, silent: true, ignoreReturnCode: false} as tr.IExecOptions);
        if (result.code === 0)
        {
github rdagumampan / yuniql / yuniql-azure-pipelines / src / install / installer.ts View on Github external
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);
        }
    }
    catch (error) {
        console.log('yuniql/error: ' + error.message);
        taskLib.setResult(taskLib.TaskResult.Failed, error.message);
    }
}
github microsoft / azure-pipelines-tasks / Tasks / FuncToolsInstallerV0 / src / utils.ts View on Github external
function sanitizeVersionString(inputVersion: string) : string{
    const version = toolLib.cleanVersion(inputVersion);
    if(!version) {
        throw new Error(tl.loc("NotAValidSemverVersion"));
    }
    
    return version;
}