How to use the azure-pipelines-task-lib.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 onlyutkarsh / gitlab-integration / tasks / DownloadRepo / DownloadRepoV1 / index.ts View on Github external
let commitId = tl.getInput("version");
        let debugOutput = tl.getVariable("system.debug");
        debugOutput = debugOutput || "false";
        let isDebugOutput: boolean = debugOutput.toLowerCase() === "true";

        // print what is supplied by the user
        tl.debug(`endpoint: ${JSON.stringify(auth)}`);
        tl.debug(`definition: ${definition}`);
        tl.debug(`branch: ${branch}`);
        tl.debug(`downloadPath: ${downloadPath}`);
        tl.debug(`versionSelector: ${versionSelector}`);
        tl.debug(`commitId: ${commitId}`);
        tl.debug(`debugOutput: ${debugOutput}`);

        if (!downloadPath || downloadPath.length === 0) {
            downloadPath = tl.getVariable("System.DefaultWorkingDirectory");
        }

        console.info(`Cleaning ${downloadPath}`);
        CleanFolder(downloadPath);
        console.info("Done");

        tl.debug("Finding repository url");
        let gitApi = new GitApi();
        let repoUrl = await gitApi.getRepoUrl(endpointUrl, definition, token);
        console.info(`Repo Url: ${url.format(repoUrl)}`);

        commitId = commitId || "";
        if (commitId === "") {
            console.info("Identifying commit id");
            if (versionSelector === "latestDefaultBranch") {
                tl.debug("Finding commit for default branch");
github microsoft / azure-pipelines-artifact-caching-tasks / Tasks / Common / packaging-common / cache / universalpublish.ts View on Github external
const version: string = `1.0.0-${hash}`;
        let accessToken: string;
        let feedUri: string;
        const publishedPackageVar: string = tl.getInput("publishedPackageVar");
        const versionRadio = 'custom';

        let internalAuthInfo: auth.InternalAuthInfo;

        const toolRunnerOptions = artifactToolRunner.getOptions();

        let sessionId: string;

        // getting inputs
        serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);

        packageName = tl.getVariable('Build.DefinitionName')
            .replace(/\s/g, "")
            .substring(0, 255)
            .toLowerCase();

        feedId = tl.getInput("feedList");

        // Setting up auth info
        accessToken = pkgLocationUtils.getSystemAccessToken();
        internalAuthInfo = new auth.InternalAuthInfo([], accessToken);

        toolRunnerOptions.env.UNIVERSAL_PUBLISH_PAT = internalAuthInfo.accessToken;

        // creating session
        const useSessionEnabled = tl.getVariable("Packaging.SavePublishMetadata");
        if (useSessionEnabled) {
            let packagingLocation: string;
github microsoft / azure-pipelines-artifact-caching-tasks / Tasks / Common / packaging-common / ArtifactToolUtilities.ts View on Github external
function _createExtractFolder(dest?: string): string {
    if (!dest) {
        // create a temp dir
        dest = path.join(tl.getVariable("Agent.TempDirectory"), "artifactTool");
    }
    tl.mkdirP(dest);
    return dest;
}
github microsoft / azure-pipelines-artifact-caching-tasks / Tasks / Common / packaging-common / cache / feedUtilities.ts View on Github external
export async function doesPackageExist(hash: string): Promise {
  const feedId = tl.getInput("feedList");
  // Getting package name from hash
  const packageId = tl
    .getVariable("Build.DefinitionName")
    .replace(/\s/g, "")
    .substring(0, 255)
    .toLowerCase();

  const version = `1.0.0-${hash}`;
  const accessToken = pkgLocationUtils.getSystemAccessToken();
  const collectionUri = process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI;

  let instance: string = "";
  const legacyRegex = /https:\/\/(\S+).visualstudio.com\S+/g;
  const newRegex = /https:\/\/dev.azure.com\/(\S+)\//g;

  const legacyUrl = legacyRegex.exec(collectionUri);
  const newUrl = newRegex.exec(collectionUri);
github microsoft / azure-pipelines-tasks / Tasks / TwineAuthenticateV0 / twineauthenticatemain.ts View on Github external
function _logTwineAuthStartupVariables() {
    try {
        const twineAuthenticateTelemetry = {
            "System.TeamFoundationCollectionUri": tl.getVariable("System.TeamFoundationCollectionUri"),
            };
        telemetry.emitTelemetry("Packaging", "TwineAuthenticate", twineAuthenticateTelemetry);
    } catch (err) {
        tl.debug(`Unable to log Twine Authenticate task init telemetry. Err:( ${err} )`);
    }
}
github geeklearningio / gl-vsts-tasks-yarn / Tasks / Yarn / packaging / provenance.ts View on Github external
private static CreateBuildSessionRequest(
    feedId: string,
    buildId: string
  ): SessionRequest {
    let buildData = {
      "System.CollectionId": tl.getVariable("System.CollectionId"),
      "System.DefinitionId": tl.getVariable("System.DefinitionId"),
      "System.TeamProjectId": tl.getVariable("System.TeamProjectId"),
      "Build.BuildId": buildId,
      "Build.BuildNumber": tl.getVariable("Build.BuildNumber"),
      "Build.DefinitionName": tl.getVariable("Build.DefinitionName"),
      "Build.Repository.Name": tl.getVariable("Build.Repository.Name"),
      "Build.Repository.Provider": tl.getVariable("Build.Repository.Provider"),
      "Build.Repository.Id": tl.getVariable("Build.Repository.Id"),
      "Build.Repository.Uri": tl.getVariable("Build.Repository.Uri"),
      "Build.SourceBranch": tl.getVariable("Build.SourceBranch"),
      "Build.SourceBranchName": tl.getVariable("Build.SourceBranchName"),
      "Build.SourceVersion": tl.getVariable("Build.SourceVersion")
    };

    var sessionRequest: SessionRequest = {
      feed: feedId,
      source: "InternalBuild",
      data: buildData
    };

    return sessionRequest;
github geeklearningio / gl-vsts-tasks-yarn / Tasks / Yarn / packaging / provenance.ts View on Github external
private static CreateBuildSessionRequest(
    feedId: string,
    buildId: string
  ): SessionRequest {
    let buildData = {
      "System.CollectionId": tl.getVariable("System.CollectionId"),
      "System.DefinitionId": tl.getVariable("System.DefinitionId"),
      "System.TeamProjectId": tl.getVariable("System.TeamProjectId"),
      "Build.BuildId": buildId,
      "Build.BuildNumber": tl.getVariable("Build.BuildNumber"),
      "Build.DefinitionName": tl.getVariable("Build.DefinitionName"),
      "Build.Repository.Name": tl.getVariable("Build.Repository.Name"),
      "Build.Repository.Provider": tl.getVariable("Build.Repository.Provider"),
      "Build.Repository.Id": tl.getVariable("Build.Repository.Id"),
      "Build.Repository.Uri": tl.getVariable("Build.Repository.Uri"),
      "Build.SourceBranch": tl.getVariable("Build.SourceBranch"),
      "Build.SourceBranchName": tl.getVariable("Build.SourceBranchName"),
      "Build.SourceVersion": tl.getVariable("Build.SourceVersion")
    };

    var sessionRequest: SessionRequest = {
      feed: feedId,
      source: "InternalBuild",
      data: buildData
    };

    return sessionRequest;
  }
}
github geeklearningio / gl-vsts-tasks-yarn / Tasks / Yarn / packaging / provenance.ts View on Github external
public static CreateSessionRequest(feedId: string): SessionRequest {
    var releaseId = tl.getVariable("Release.ReleaseId");
    if (releaseId != null) {
      return ProvenanceHelper.CreateReleaseSessionRequest(feedId, releaseId);
    }

    var buildId = tl.getVariable("Build.BuildId");
    if (buildId != null) {
      return ProvenanceHelper.CreateBuildSessionRequest(feedId, buildId);
    }

    throw new Error("Could not resolve Release.ReleaseId or Build.BuildId");
  }
github geeklearningio / gl-vsts-tasks-yarn / Tasks / Yarn / packaging / provenance.ts View on Github external
private static CreateReleaseSessionRequest(
    feedId: string,
    releaseId: string
  ): SessionRequest {
    let releaseData = {
      "System.CollectionId": tl.getVariable("System.CollectionId"),
      "System.TeamProjectId": tl.getVariable("System.TeamProjectId"),
      "Release.ReleaseId": releaseId,
      "Release.ReleaseName": tl.getVariable("Release.ReleaseName"),
      "Release.DefinitionName": tl.getVariable("Release.DefinitionName"),
      "Release.DefinitionId": tl.getVariable("Release.DefinitionId")
    };

    var sessionRequest: SessionRequest = {
      feed: feedId,
      source: "InternalRelease",
      data: releaseData
    };

    return sessionRequest;
  }