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

To help you get started, we’ve selected a few azure-pipelines-task-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 / AndroidSigningV2 / androidsigning.ts View on Github external
var jarsigning = (fn: string) => {
    // file must exist
    tl.checkPath(fn, 'file to sign');

    var jarsigner = tl.which("jarsigner", false);
    if (!jarsigner) {
        var java_home = tl.getVariable('JAVA_HOME');
        if (!java_home) {
            throw tl.loc('JavaHomeNotSet');
        }

        jarsigner = tl.resolve(java_home, 'bin', 'jarsigner');
    }

    var jarsignerRunner = tl.tool(jarsigner);

    // Get keystore file path for signing
    var keystoreFile = tl.getTaskVariable('KEYSTORE_FILE_PATH');

    // Get keystore alias
    var keystoreAlias = tl.getInput('keystoreAlias', true);

    var keystorePass = tl.getInput('keystorePass', false);

    var keyPass = tl.getInput('keyPass', false);

    var jarsignerArguments = tl.getInput('jarsignerArguments', false);

    jarsignerRunner.arg(['-keystore', keystoreFile]);

    if (keystorePass) {
github microsoft / azure-pipelines-tasks / Tasks / AndroidSigningV2 / androidsigning.ts View on Github external
}

        var zipalignToolsList = tl.findMatch(tl.resolve(android_home, 'build-tools'), "zipalign*", null, { matchBase: true });

        if (!zipalignToolsList || zipalignToolsList.length === 0) {
            throw tl.loc('CouldNotFindZipalignInAndroidHome', android_home);
        }

        zipaligner = zipalignToolsList[0];
    }

    if (!zipaligner) {
        throw tl.loc('CouldNotFindZipalign');
    }

    var zipalignRunner = tl.tool(zipaligner);

    // alignment must be 4 or play store will reject, hard code this to avoid user errors
    zipalignRunner.arg(["-v", "4"]);

    var unalignedFn = fn + ".unaligned";
    var success = tl.mv(fn, unalignedFn, '-f', false);

    zipalignRunner.arg([unalignedFn, fn]);
    return zipalignRunner.exec(null);
}
github microsoft / azure-pipelines-tasks / Tasks / UseDotNetV2 / versionfetcher.ts View on Github external
private detectMachineOS(): string[] {
        let osSuffix = [];
        let scriptRunner: trm.ToolRunner;

        try {
            console.log(tl.loc("DetectingPlatform"));
            if (tl.osType().match(/^Win/)) {
                let escapedScript = path.join(this.getCurrentDir(), 'externals', 'get-os-platform.ps1').replace(/'/g, "''");
                let command = `& '${escapedScript}'`

                let powershellPath = tl.which('powershell', true);
                scriptRunner = tl.tool(powershellPath)
                    .line('-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command')
                    .arg(command);
            }
            else {
                let scriptPath = path.join(this.getCurrentDir(), 'externals', 'get-os-distro.sh');
                this.setFileAttribute(scriptPath, "777");

                scriptRunner = tl.tool(tl.which(scriptPath, true));
            }

            let result: trm.IExecSyncResult = scriptRunner.execSync();

            if (result.code != 0) {
                throw tl.loc("getMachinePlatformFailed", result.error ? result.error.message : result.stderr);
            }
github microsoft / azure-pipelines-tasks / Tasks / DotNetCoreInstallerV1 / versionfetcher.ts View on Github external
private detectMachineOS(): string[] {
        let osSuffix = [];
        let scriptRunner: trm.ToolRunner;

        try {
            console.log(tl.loc("DetectingPlatform"));
            if (tl.osType().match(/^Win/)) {
                let escapedScript = path.join(this.getCurrentDir(), 'externals', 'get-os-platform.ps1').replace(/'/g, "''");
                let command = `& '${escapedScript}'`

                let powershellPath = tl.which('powershell', true);
                scriptRunner = tl.tool(powershellPath)
                    .line('-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command')
                    .arg(command);
            }
            else {
                let scriptPath = path.join(this.getCurrentDir(), 'externals', 'get-os-distro.sh');
                this.setFileAttribute(scriptPath, "777");

                scriptRunner = tl.tool(tl.which(scriptPath, true));
            }

            let result: trm.IExecSyncResult = scriptRunner.execSync();

            if (result.code != 0) {
                throw tl.loc("getMachinePlatformFailed", result.error ? result.error.message : result.stderr);
            }
github microsoft / azure-pipelines-tasks / Tasks / Common / kubernetes-common-v2 / kubectl-object-model.ts View on Github external
public describe(resourceType: string, resourceName: string, silent?: boolean): IExecSyncResult {
        const command = tl.tool(this.kubectlPath);
        command.arg('describe');
        command.arg([resourceType, resourceName]);
        return this.execute(command, silent);
    }
github microsoft / azure-pipelines-tasks / Tasks / Common / kubernetes-common-v2 / kubectl-object-model.ts View on Github external
public annotate(resourceType: string, resourceName: string, annotations: string[], overwrite?: boolean): IExecSyncResult {
        const command = tl.tool(this.kubectlPath);
        command.arg('annotate');
        command.arg([resourceType, resourceName]);
        command.arg(annotations);
        if (!!overwrite) { command.arg(`--overwrite`); }
        return this.execute(command);
    }
github microsoft / azure-pipelines-tasks / Tasks / Common / kubernetes-common-v2 / kubectl-object-model.ts View on Github external
public scale(resourceType: string, resourceName: string, replicas: any) {
        const command = tl.tool(this.kubectlPath);
        command.arg('scale');
        command.arg(resourceType + '/' + resourceName);
        command.arg(`--replicas=${replicas}`);
        return this.execute(command);
    }
github aws / aws-vsts-tools / Tasks / AWSShellScript / TaskOperations.ts View on Github external
private async translateWindowsPath(windowsPath: string): Promise {
        const pwd = tool(which('bash', true))
            .arg('--noprofile')
            .arg('--norc')
            .arg('-c')
            .arg('pwd')

        const options = {
            cwd: windowsPath,
            errStream: process.stdout,
            outStream: process.stdout,
            failOnStdErr: true,
            ignoreReturnCode: false
        }
        let unixPath = ''
        pwd.on('stdout', (c: string | symbol) => (unixPath += c.toString()))
        await pwd.exec((options as unknown) as IExecOptions)
        unixPath = unixPath.trim()
github microsoft / azure-pipelines-tasks / Tasks / AzureFunctionOnKubernetesV0 / src / utils / commandHelper.ts View on Github external
public getDeleteSecretCommand(secretName: string, namespace: string): tr.ToolRunner {
        const command = tl.tool(this.kubectlPath);
        command.arg(['delete', 'secret', secretName]);
        if (namespace) {
            command.arg(['--namespace', namespace]);
        }

        return command;
    }
}
github microsoft / azure-pipelines-tasks / Tasks / Common / kubernetes-common-v2 / kubectl-object-model.ts View on Github external
public getAllPods(): IExecSyncResult {
        const command = tl.tool(this.kubectlPath);
        command.arg('get');
        command.arg('pods');
        command.arg(['-o', 'json']);
        return this.execute(command, true);
    }