How to use the azure-pipelines-task-lib/task.getInput 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 jfrog / artifactory-vsts-extension / tasks / ArtifactoryConan / conanBuild.js View on Github external
let handleAddRemoteCommand = async(function () {
    let remoteName = tl.getInput("remoteName", true);
    let artifactoryService = tl.getInput("artifactoryService", true);
    let artifactoryUrl = tl.getEndpointUrl(artifactoryService, false);
    let artifactoryUser = tl.getEndpointAuthorizationParameter(artifactoryService, "username", true);
    let artifactoryPassword = tl.getEndpointAuthorizationParameter(artifactoryService, "password", true);
    let artifactoryAccessToken = tl.getEndpointAuthorizationParameter(artifactoryService, "apitoken", true);
    let conanRepo = tl.getInput("conanRepo", true);
    let purgeExistingRemotes = tl.getBoolInput("purgeExistingRemotes", true);

    if (artifactoryAccessToken) {
        // Access token is not supported.
        console.error("Access Token is not supported for authentication with Artifactory, please configure Artifactory service connection" +
            " to work with basic authentication.");
        setTaskResult(false);
        return;
    }
github microsoft / azure-pipelines-tasks / Tasks / NuGetPublisherV0 / nugetpublisher.ts View on Github external
nutil.setConsoleCodePage();

        // read inputs
        let searchPattern = tl.getPathInput("searchPattern", true, false);
        let allowEmptyNupkgMatch = tl.getBoolInput("continueOnEmptyNupkgMatch");
        let filesList = nutil.resolveFilterSpec(
            searchPattern,
            tl.getVariable("System.DefaultWorkingDirectory") || process.cwd(),
            allowEmptyNupkgMatch);
        filesList.forEach(packageFile => {
            if (!tl.stats(packageFile).isFile()) {
                throw new Error(tl.loc("NotARegularFile", packageFile));
            }
        });

        let connectedServiceName = tl.getInput("connectedServiceName");
        let internalFeedUri = tl.getInput("feedName");
        let nuGetAdditionalArgs = tl.getInput("nuGetAdditionalArgs");
        let verbosity = tl.getInput("verbosity");

        let nuGetFeedType = tl.getInput("nuGetFeedType") || "external";
        // make sure the feed type is an expected one
        let normalizedNuGetFeedType
            = ["internal", "external"].find(x => nuGetFeedType.toUpperCase() === x.toUpperCase());
        if (!normalizedNuGetFeedType) {
            throw new Error(tl.loc("UnknownFeedType", nuGetFeedType));
        }

        nuGetFeedType = normalizedNuGetFeedType;

        // due to a bug where we accidentally allowed nuGetPath to be surrounded by quotes before,
        // locateNuGetExe() will strip them and check for existence there.
github microsoft / azure-pipelines-tasks / Tasks / UseGoV1 / installer.ts View on Github external
function setGoEnvironmentVariables(goRoot: string) {
    tl.setVariable('GOROOT', goRoot);

    const goPath: string = tl.getInput("goPath", false);
    const goBin: string = tl.getInput("goBin", false);

    // set GOPATH and GOBIN as user value
    if (!util.isNullOrUndefined(goPath)) {
        tl.setVariable("GOPATH", goPath);
    }
    if (!util.isNullOrUndefined(goBin)) {
        tl.setVariable("GOBIN", goBin);
    }
}
github microsoft / azure-pipelines-tasks / Tasks / FtpUploadV2 / ftpuploadtask.ts View on Github external
// server endpoint
        const serverEndpoint: string = tl.getInput("serverEndpoint", true);
        serverEndpointUrl = url.parse(
            tl.getEndpointUrl(serverEndpoint, false)
        );

        const serverEndpointAuth: tl.EndpointAuthorization = tl.getEndpointAuthorization(
            serverEndpoint,
            false
        );
        username = serverEndpointAuth["parameters"]["username"];
        password = serverEndpointAuth["parameters"]["password"];
    } else {
        // user entered credentials directly
        serverEndpointUrl = url.parse(tl.getInput("serverUrl", true));
        username = tl.getInput("username", true);
        password = tl.getInput("password", true);
    }

    return {
        serverEndpointUrl: serverEndpointUrl,
        username: username,
        password: password,

        // other standard options
        rootFolder: tl.getPathInput("rootFolder", true),
        filePatterns: tl.getDelimitedInput("filePatterns", "\n", true),
        remotePath: tl.getInput("remotePath", true).trim().replace(/\\/gi, "/"), // use forward slashes always

        // advanced options
        clean: tl.getBoolInput("clean", true),
        cleanContents: tl.getBoolInput("cleanContents", false),
github jfrog / artifactory-vsts-extension / tasks / ArtifactoryPublishBuildInfo / publishBuildInfo.js View on Github external
function RunTaskCbk(cliPath) {
    let buildName = tl.getInput('buildName', true);
    let buildNumber = tl.getInput('buildNumber', true);
    let workDir = tl.getVariable('System.DefaultWorkingDirectory');
    if (!workDir) {
        tl.setResult(tl.TaskResult.Failed, "Failed getting default working directory.");
        return;
    }

    // Get input parameters
    let artifactoryService = tl.getInput("artifactoryService", false);
    let artifactoryUrl = tl.getEndpointUrl(artifactoryService, false);
    let excludeEnvVars = tl.getInput("excludeEnvVars", false);

    let cliCommand = utils.cliJoin(cliPath, cliBuildPublishCommand, utils.quote(buildName), utils.quote(buildNumber), "--url=" + utils.quote(artifactoryUrl), "--env-exclude=" + utils.quote(excludeEnvVars));
    cliCommand = addBuildUrl(cliCommand);
    cliCommand = utils.addArtifactoryCredentials(cliCommand, artifactoryService);

    try {
        utils.executeCliCommand(cliCommand, workDir);
        attachBuildInfoUrl(buildName, buildNumber, workDir);
        tl.setResult(tl.TaskResult.Succeeded, "Build Succeeded.");
    } catch (ex) {
        tl.setResult(tl.TaskResult.Failed, ex);
    }
}
github microsoft / azure-devops-extension-tasks / BuildTasks / Common / Common.ts View on Github external
export function validateAndSetTfxManifestArguments(tfx: ToolRunner): (() => void) {
    const rootFolder = tl.getInput("rootFolder", false);
    tfx.argIf(rootFolder, ["--root", rootFolder]);

    
    const globsManifest = tl.getDelimitedInput("patternManifest", "\n", false);
    tfx.argIf(globsManifest.length, ["--manifest-globs"]);
    tfx.argIf(globsManifest.length, globsManifest);

    // Overrides manifest file
    const publisher = tl.getInput("publisherId", false);

    const localizationRoot = tl.getInput("localizationRoot", false);
    tfx.argIf(localizationRoot, ["--loc-root", localizationRoot]);

    let extensionId = tl.getInput("extensionId", false);
    const extensionTag = tl.getInput("extensionTag", false);

    if (extensionId && extensionTag) {
        extensionId += extensionTag;
        tl.debug(`Overriding extension id to: ${extensionId}`);
    }

    // for backwards compat check both "method" and "fileType"
    switch (tl.getInput("method", false) || tl.getInput("fileType", false)) {
        // for backwards compat trigger on both "manifest" and "id"
        case "manifest":
        case "id":
        default:
github microsoft / azure-pipelines-tasks / Tasks / AzureFunctionOnKubernetesV0 / src / deploy.ts View on Github external
'use strict';

import * as yaml from 'js-yaml';
import * as tl from 'azure-pipelines-task-lib/task';
import * as tr from "azure-pipelines-task-lib/toolrunner";
import { CommandHelper } from './utils/commandHelper';
import { DockerConnection } from './dockerConnection';
import { Kubectl, Resource } from 'kubernetes-common-v2/kubectl-object-model';
import * as FileHelper from './utils/fileHelper';
import * as KubernetesConstants from 'kubernetes-common-v2/kubernetesconstants';
import * as KubernetesManifestUtility from 'kubernetes-common-v2/kubernetesmanifestutility';
import * as CommonUtils from 'kubernetes-common-v2/utility';

const secretName = tl.getInput('secretName');
const appName = tl.getInput('appName', true);
const namespace = getKubernetesNamespace();
const dockerHubNamespace = tl.getInput('dockerHubNamespace');
const args = tl.getInput('arguments');
const funcRootDir = tl.getInput('functionRootDirectory', true);
const waitForStability = tl.getBoolInput('waitForStability');
const isDryRun = (args && args.includes('--dry-run')) ? true : false;

export async function deploy(commandHelper: CommandHelper, dockerConnection: DockerConnection) {
    let pullSecretName: string = '';
    if (!isDryRun) {
        // create pull secret if it is not dry-run
        pullSecretName = createImagePullSecret(commandHelper);
    }

    // invoke func kubernetes deploy
    funcDeploy(commandHelper, dockerConnection, pullSecretName);
github rdagumampan / yuniql / yuniql-azure-pipelines / src / install / useyuniql.ts View on Github external
async function run() {
    try {
        //get target version
        const version = taskLib.getInput('version', false);
        console.log('yuniql/input_version: ' + version);
        if (version) {
            await installer.getYuniql(version, true);
        }
    }
    catch (error) {
        console.log('yuniql/error: ' + error.message);
        taskLib.setResult(taskLib.TaskResult.Failed, error.message);
    }
}
github microsoft / google-play-vsts-extension / Tasks / google-play-release-bundle / GooglePlay.ts View on Github external
tl.debug('Prepare task inputs.');

        const authType: string = tl.getInput('authType', true);
        let key: googleutil.ClientKey = {};
        if (authType === 'JsonFile') {
            const serviceAccountKeyFile: string = tl.getPathInput('serviceAccountKey', true, true);

            const stats: tl.FsStats = tl.stats(serviceAccountKeyFile);
            if (stats && stats.isFile()) {
                key = require(serviceAccountKeyFile);
            } else {
                tl.debug(`The service account file path ${serviceAccountKeyFile} points to a directory.`);
                throw new Error(tl.loc('InvalidAuthFile', serviceAccountKeyFile));
            }
        } else if (authType === 'ServiceEndpoint') {
            let serviceEndpoint: tl.EndpointAuthorization = tl.getEndpointAuthorization(tl.getInput('serviceEndpoint', true), false);
            key.client_email = serviceEndpoint.parameters['username'];
            key.private_key = serviceEndpoint.parameters['password'].replace(/\\n/g, '\n');
        }

        const packageName: string = tl.getInput('applicationId', true);
        tl.debug(`Application identifier: ${packageName}`);

        const mainBundlePattern = tl.getPathInput('bundleFile', true);
        tl.debug(`Main bundle pattern: ${mainBundlePattern}`);

        const bundleFile: string = resolveGlobPath(mainBundlePattern);
        tl.checkPath(bundleFile, 'bundleFile');
        console.log(tl.loc('FoundMainBundle', bundleFile));
        tl.debug(`Found the main bundle file: ${bundleFile}.`);

        const versionCodeFilterType: string = tl.getInput('versionCodeFilterType', false) || 'all';
github microsoft / azure-pipelines-tasks / Tasks / NpmV1 / npm.ts View on Github external
break;
            case NpmCommand.Publish:
                npmRegistriesAry = [await npmPublish.getPublishRegistry(packagingLocation)];
                break;
        }
        for (const registry of npmRegistriesAry) {
            registryUrlAry.push(registry.url);
        }

        const npmTelem = {
            'command': command,
            'verbose': tl.getInput(NpmTaskInput.Verbose),
            'customRegistry': tl.getInput(NpmTaskInput.CustomRegistry),
            'customFeed': tl.getInput(NpmTaskInput.CustomFeed),
            'customEndpoint': tl.getInput(NpmTaskInput.CustomEndpoint),
            'publishRegistry': tl.getInput(NpmTaskInput.PublishRegistry),
            'publishFeed': tl.getInput(NpmTaskInput.PublishFeed),
            'publishEndpoint': tl.getInput(NpmTaskInput.PublishEndpoint),
            'npmVersion': version,
            'registries': registryUrlAry
        };

        telemetry.emitTelemetry('Packaging', 'npm', npmTelem);
    } catch (err) {
        tl.debug(`Unable to log NPM task telemetry. Err:( ${err} )`);
    }
}