当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript azure-pipelines-task-lib.getVariable函数代码示例

本文整理汇总了TypeScript中azure-pipelines-task-lib.getVariable函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getVariable函数的具体用法?TypeScript getVariable怎么用?TypeScript getVariable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getVariable函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: CreateSessionRequest

    /* Creates a session request with default data provided by the build variables */
    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");
    }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:15,代码来源:provenance.ts

示例2: GetSessionId

 public static async GetSessionId(
     feedId: string,
     project: string,
     protocol: string,
     baseUrl: string,
     handlers: VsoBaseInterfaces.IRequestHandler[],
     options: VsoBaseInterfaces.IRequestOptions): Promise<string> {
            
     const publishPackageMetadata = tl.getInput("publishPackageMetadata");
     let shouldCreateSession = publishPackageMetadata && publishPackageMetadata.toLowerCase() == 'true';
     if (shouldCreateSession) {
         const useSessionEnabled = tl.getVariable("Packaging.SavePublishMetadata");
         shouldCreateSession = shouldCreateSession && !(useSessionEnabled && useSessionEnabled.toLowerCase() == 'false')
     }
     if (shouldCreateSession) {
         tl.debug("Creating provenance session to save pipeline metadata. This can be disabled in the task settings, or by setting build variable Packaging.SavePublishMetadata to false");
         const prov = new ProvenanceApi(baseUrl, handlers, options);
         const sessionRequest = ProvenanceHelper.CreateSessionRequest(feedId);
         try {
             const session = await prov.createSession(sessionRequest, protocol, project);
             return session.sessionId;
         } catch (error) {
             tl.warning(tl.loc("Warning_SessionCreationFailed", JSON.stringify(error)));
         }
     }
     return feedId;
 }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:27,代码来源:provenance.ts

示例3: getArtifactToolFromService

export async function getArtifactToolFromService(serviceUri: string, accessToken: string, toolName: string){

    const overrideArtifactToolPath = tl.getVariable("UPack.OverrideArtifactToolPath");
    if (overrideArtifactToolPath != null) {
        return getArtifactToolLocation(overrideArtifactToolPath);
    }

    let osName = tl.osType();
    let arch = os.arch();
    if (osName === "Windows_NT"){
        osName = "windows";
    }
    if (arch === "x64"){
        arch = "amd64";
    }

    // https://github.com/nodejs/node-v0.x-archive/issues/2862
    if (arch === "ia32") {
        if (process.env.PROCESSOR_ARCHITEW6432 != null && process.env.PROCESSOR_ARCHITEW6432.toUpperCase() === "AMD64") {
            arch = "amd64";
        }
    }

    if (arch.toLowerCase() !== "amd64") {
        throw new Error(tl.loc("Error_ProcessorArchitectureNotSupported"));
    }

    const blobstoreAreaName = "clienttools";
    const blobstoreAreaId = "187ec90d-dd1e-4ec6-8c57-937d979261e5";
    const ApiVersion = "5.0-preview";

    const blobstoreConnection = pkgLocationUtils.getWebApiWithProxy(serviceUri, accessToken);

    const artifactToolGetUrl = await pkgLocationUtils.Retry(async () => {
        return await blobstoreConnection.vsoClient.getVersioningData(ApiVersion,
        blobstoreAreaName, blobstoreAreaId, { toolName }, {osName, arch});
    }, 4, 100);

    const artifactToolUri =  await blobstoreConnection.rest.get(artifactToolGetUrl.requestUrl);

    if (artifactToolUri.statusCode !== 200) {
        tl.debug(tl.loc("Error_UnexpectedErrorFailedToGetToolMetadata", artifactToolUri.result.toString()));
        throw new Error(tl.loc("Error_UnexpectedErrorFailedToGetToolMetadata", artifactToolGetUrl.requestUrl));
    }

    let artifactToolPath = toollib.findLocalTool(toolName, artifactToolUri.result['version']);
    if (!artifactToolPath) {
        tl.debug(tl.loc("Info_DownloadingArtifactTool", artifactToolUri.result['uri']));

        const zippedToolsDir: string = await toollib.downloadTool(artifactToolUri.result['uri']);

        tl.debug("Downloaded zipped artifact tool to " + zippedToolsDir);
        const unzippedToolsDir = await extractZip(zippedToolsDir);

        artifactToolPath = await toollib.cacheDir(unzippedToolsDir, "ArtifactTool", artifactToolUri.result['version']);
    } else {
        tl.debug(tl.loc("Info_ResolvedToolFromCache", artifactToolPath));
    }
    return getArtifactToolLocation(artifactToolPath);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:60,代码来源:ArtifactToolUtilities.ts

示例4: _createExtractFolder

function _createExtractFolder(dest?: string): string {
    if (!dest) {
        // create a temp dir
        dest = path.join(tl.getVariable("Agent.TempDirectory"), "artifactTool");
    }
    tl.mkdirP(dest);
    return dest;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:8,代码来源:ArtifactToolUtilities.ts

示例5: CreateReleaseSessionRequest

    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;
    }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:18,代码来源:provenance.ts

示例6: _logTwineAuthStartupVariables

 // Telemetry
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} )`);
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:11,代码来源:twineauthenticatemain.ts

示例7: _logUniversalStartupVariables

function _logUniversalStartupVariables(artifactToolPath: string) {
    try {
        let universalPackagesTelemetry = {
            "command": tl.getInput("command"),
            "buildProperties": tl.getInput("buildProperties"),
            "basePath": tl.getInput("basePath"),
            "System.TeamFoundationCollectionUri": tl.getVariable("System.TeamFoundationCollectionUri"),
            "verbosity": tl.getInput("verbosity"),
            "solution": tl.getInput("solution"),
            "artifactToolPath": artifactToolPath,
            };

        telemetry.emitTelemetry("Packaging", "UniversalPackages", universalPackagesTelemetry);
    } catch (err) {
        tl.debug(`Unable to log Universal Packages task init telemetry. Err:( ${err} )`);
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:17,代码来源:universalmain.ts

示例8: main

async function main(): Promise<void> {
    tl.setResourcePath(path.join(__dirname, "task.json"));

    // Getting artifact tool
    tl.debug("Getting artifact tool");
    let artifactToolPath: string;

    try {
        const serverType = tl.getVariable("System.ServerType");
        if (!serverType || serverType.toLowerCase() !== "hosted"){
            throw new Error(tl.loc("Error_UniversalPackagesNotSupportedOnPrem"));
        }

        const localAccessToken = pkgLocationUtils.getSystemAccessToken();
        const serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
        const blobUri = await pkgLocationUtils.getBlobstoreUriFromBaseServiceUri(
            serviceUri,
            localAccessToken);

        // Finding the artifact tool directory
        artifactToolPath = await artifactToolUtilities.getArtifactToolFromService(
            blobUri,
            localAccessToken,
            "artifacttool");
    }
    catch (error) {
        tl.setResult(tl.TaskResult.Failed, tl.loc("FailedToGetArtifactTool", error.message));
        return;
    } finally{
        _logUniversalStartupVariables(artifactToolPath);
    }
    // Calling the command. download/publish
    const universalPackageCommand = tl.getInput("command", true);
    switch (universalPackageCommand) {
        case "download":
            universalDownload.run(artifactToolPath);
            break;
        case "publish":
            universalPublish.run(artifactToolPath);
            break;
        default:
            tl.setResult(tl.TaskResult.Failed, tl.loc("Error_CommandNotRecognized", universalPackageCommand));
            break;
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:45,代码来源:universalmain.ts

示例9: downloadPackageUsingArtifactTool

function downloadPackageUsingArtifactTool(
    downloadPath: string,
    options: artifactToolRunner.IArtifactToolOptions,
    execOptions: IExecOptions,
    filterPattern: string
) {
    let command = new Array<string>();
    var verbosity = tl.getVariable("Packaging.ArtifactTool.Verbosity") || "Error";
    
    command.push("universal", "download",
        "--feed", options.feedId,
        "--service", options.accountUrl,
        "--package-name", options.packageName,
        "--package-version", options.packageVersion,
        "--path", downloadPath,
        "--patvar", "UNIVERSAL_DOWNLOAD_PAT",
        "--verbosity", verbosity,
        "--filter", filterPattern);

    console.log(tl.loc("Info_Downloading", options.packageName, options.packageVersion, options.feedId));
    const execResult: IExecSyncResult = artifactToolRunner.runArtifactTool(
        options.artifactToolPath,
        command,
        execOptions
    );
    if (execResult.code === 0) {
        return;
    }

    telemetry.logResult("DownloadPackage", "UniversalPackagesCommand", execResult.code);
    throw new Error(
        tl.loc(
            "Error_UnexpectedErrorArtifactToolDownload",
            execResult.code,
            execResult.stderr ? execResult.stderr.trim() : execResult.stderr
        )
    );
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:38,代码来源:universal.ts

示例10: main

async function main(): Promise<void> {
    tl.setResourcePath(path.join(__dirname, "task.json"));

    try {
        let packagingLocation: string;

        let pipEnvVar: string = "";
        if (tl.getVariable("PIP_EXTRA_INDEX_URL")) {
            pipEnvVar = tl.getVariable("PIP_EXTRA_INDEX_URL");
        }

        const feedIds  = tl.getDelimitedInput("feedList", ",");
        const serverType = tl.getVariable("System.ServerType");

        // Local feeds
        if (feedIds)
        {
            if (!serverType || serverType.toLowerCase() !== "hosted"){
                throw new Error(tl.loc("Error_PythonInternalFeedsNotSupportedOnprem"));
            }
            tl.debug(tl.loc("Info_AddingInternalFeeds", feedIds.length));
            const serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
            const localAccessToken = pkgLocationUtils.getSystemAccessToken();
            try {
                // This call is to get the packaging URI(abc.pkgs.vs.com) which is same for all protocols.
                packagingLocation = await pkgLocationUtils.getNuGetUriFromBaseServiceUri(
                    serviceUri,
                    localAccessToken);
            } catch (error) {
                tl.debug(tl.loc("FailedToGetPackagingUri"));
                tl.debug(JSON.stringify(error));
                packagingLocation = serviceUri;
            }

            for (const feedId of feedIds) {
                const feedUri = await pkgLocationUtils.getFeedRegistryUrl(
                    packagingLocation, 
                    pkgLocationUtils.RegistryType.PyPiSimple, 
                    feedId,
                    null,
                    localAccessToken);
                const pipUri = utils.formPipCompatibleUri("build", localAccessToken, feedUri);
                pipEnvVar = pipEnvVar + " " + pipUri;
            }
        }

        // external service endpoints
        let endpointNames = tl.getDelimitedInput("externalSources", ',');

        const externalEndpoints = auth.getExternalAuthInfoArray(endpointNames);
        externalEndpoints.forEach((id) => {
            const externalPipUri = utils.formPipCompatibleUri(id.username, id.password, id.packageSource.feedUri);
            pipEnvVar = pipEnvVar + " " + externalPipUri;
        });

        // Setting variable
        tl.setVariable("PIP_EXTRA_INDEX_URL", pipEnvVar, false);
        console.log(tl.loc("Info_SuccessAddingAuth", feedIds.length, externalEndpoints.length));

        const pipauthvar = tl.getVariable("PIP_EXTRA_INDEX_URL");
        if (pipauthvar.length < pipEnvVar.length){
            tl.warning(tl.loc("Warn_TooManyFeedEntries"));
        }
        tl.debug(pipEnvVar);
    }
    catch (error) {
        tl.error(error);
        tl.setResult(tl.TaskResult.Failed, tl.loc("FailedToAddAuthentication"));
        return;
    } finally{
        _logPipAuthStartupVariables();
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:73,代码来源:pipauthenticatemain.ts


注:本文中的azure-pipelines-task-lib.getVariable函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。