How to use the azure-pipelines-task-lib/task.getVariable 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 / Common / kubernetes-common-v2 / image-metadata-helper.ts View on Github external
import * as util from "util";
import * as yaml from 'js-yaml';

const matchPatternForImageName = new RegExp(/\:\/\/(.+?)\@/);
const matchPatternForDigest = new RegExp(/\@sha256\:(.+)/);
const matchPatternForFileArgument = new RegExp(/-f\s|-filename\s/);
const matchPatternForServerUrl = new RegExp(/https\:\/\/(.+)/);
const matchPatternForSource = new RegExp(/source:(.+)/ig);
const matchPatternForChartPath = new RegExp(/chart path:(.+)/i);
const orgUrl = tl.getVariable('System.TeamFoundationCollectionUri');
const build = "build";
const hostType = tl.getVariable("System.HostType").toLowerCase();
const isBuild = hostType === build;
const deploymentTypes: string[] = ["deployment", "replicaset", "daemonset", "pod", "statefulset"];
const workingDirectory = tl.getVariable("System.DefaultWorkingDirectory");
const branch = tl.getVariable("Build.SourceBranchName") || tl.getVariable("Build.SourceBranch");
const repositoryProvider = tl.getVariable("Build.Repository.Provider");
const repositoryUrl = tl.getVariable("Build.Repository.Uri");
const pipelineUrlLabel = "Pipeline_Url";
const clusterUrlLabel = "Cluster_Url";
const manifestUrlLabel = "Manifest_Url";

// ToDo: Add UTs for public methods
export function getDeploymentMetadata(deploymentObject: any, allPods: any, deploymentStrategy: string, clusterInfo: any, manifestUrls: string[]): any {
    let imageIds: string[] = [];
    let containers = [];
    try {
        let kind: string = deploymentObject.kind;
        if (isPodEntity(kind)) {
            containers = deploymentObject.spec.containers;
        }
        else {
github microsoft / azure-pipelines-tasks / Tasks / Common / codeanalysis-common / Common / CodeAnalysisOrchestrator.ts View on Github external
private checkBuildContext(): boolean {
        let requiredVariables: string[] = ['System.DefaultWorkingDirectory', 'build.artifactStagingDirectory', 'build.buildNumber'];

        for (let requiredVariable of requiredVariables) {
            if (!tl.getVariable(requiredVariable)) {
                console.log(tl.loc('codeAnalysisDisabled', requiredVariable));
                return false;
            }
        }

        return true;
    }
}
github microsoft / azure-pipelines-tasks / Tasks / NuGetRestoreV1 / Tests / NuGetConfigHelper-mock.ts View on Github external
import * as tl from "azure-pipelines-task-lib/task";

export class NuGetConfigHelper {

    tempNugetConfigPath = tl.getVariable("Agent.HomeDirectory") + "\\tempNuGet_.config";
    
    getSourcesFromConfig() {
        tl.debug("getting package sources");
        let result = [{ feedName: "mockFeedName", feedUri: "mockFeedUri" }];
        return result;
    }
    
    setSources(packageSources, includeAuth) {
        packageSources.forEach((source) => {
            tl.debug(`adding package source uri: ${source.feedUri}`);
        });
    }
}
github microsoft / azure-pipelines-tasks / Tasks / KubernetesManifestV0 / src / models / kubernetesconnection.ts View on Github external
public close() {
        if (tl.getVariable('KUBECONFIG')) {
            tl.setVariable('KUBECONFIG', '');
        }
    }
}
github microsoft / azure-pipelines-tasks / Tasks / Common / docker-common-v2 / dockercommandutils.ts View on Github external
export function getPipelineUrl(): string {
    let pipelineUrl = "";
    const pipelineId = tl.getVariable("System.DefinitionId");
    if (isBuild) {
        pipelineUrl = orgUrl + tl.getVariable("System.TeamProject") + "/_build?definitionId=" + pipelineId;
    }
    else {
        pipelineUrl = orgUrl + tl.getVariable("System.TeamProject") + "/_release?definitionId=" + pipelineId;
    }

    return pipelineUrl;
}
github alcideio / pipeline / azure-devops / tasks / advisor / utilities.ts View on Github external
export function getTempDirectory(): string {
    return tl.getVariable('agent.tempDirectory') || os.tmpdir();
}
github microsoft / azure-pipelines-tasks / Tasks / Common / kubernetes-common-v2 / image-metadata-helper.ts View on Github external
function getEnvironmentResourceAddress(clusterUrl: any): string {
    const environmentName = tl.getVariable("Environment.Name");
    const environmentResourceName = tl.getVariable("Environment.ResourceName");
    if (!environmentName && !environmentResourceName) {
        if (clusterUrl && clusterUrl["url"]) {
            return clusterUrl["url"];
        }

        return "";
    }

    return util.format("%s/%s", environmentName, environmentResourceName);
}
github microsoft / azure-pipelines-tasks / Tasks / Common / docker-common-v2 / containerconnection.ts View on Github external
private getExistingDockerConfigFilePath(): string {
        this.configurationDirPath = tl.getVariable("DOCKER_CONFIG");
        let configurationFilePath = this.configurationDirPath ? path.join(this.configurationDirPath, "config.json") : "";                
        if (this.configurationDirPath && this.isPathInTempDirectory(configurationFilePath) && fs.existsSync(configurationFilePath)) {
            return configurationFilePath;
        }

        return null;
    }
github microsoft / azure-pipelines-tasks / Tasks / UseDotNetV2 / versionfetcher.ts View on Github external
constructor(explicitVersioning: boolean = false) {
        this.explicitVersioning = explicitVersioning;
        let proxyUrl: string = tl.getVariable("agent.proxyurl");
        var requestOptions: httpInterfaces.IRequestOptions = proxyUrl ? {
            proxy: {
                proxyUrl: proxyUrl,
                proxyUsername: tl.getVariable("agent.proxyusername"),
                proxyPassword: tl.getVariable("agent.proxypassword"),
                proxyBypassHosts: tl.getVariable("agent.proxybypasslist") ? JSON.parse(tl.getVariable("agent.proxybypasslist")) : null
            }
        } : {};

        this.httpCallbackClient = new httpClient.HttpClient(tl.getVariable("AZURE_HTTP_USER_AGENT"), null, requestOptions);
        this.channels = [];
    }
github microsoft / azure-pipelines-tasks / Tasks / Common / docker-common-v2 / containerconnection.ts View on Github external
private removeConfigDirAndUnsetEnvVariable(): void {
        let dockerConfigDirPath = tl.getVariable("DOCKER_CONFIG");
        if (dockerConfigDirPath && this.isPathInTempDirectory(dockerConfigDirPath) && fs.existsSync(dockerConfigDirPath)) {
            tl.debug(tl.loc('DeletingDockerConfigDirectory', dockerConfigDirPath));
            del.sync(dockerConfigDirPath, {force: true});
        }
        
        this.unsetEnvironmentVariable();
    }