當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vsts-task-lib.getVariable函數代碼示例

本文整理匯總了TypeScript中vsts-task-lib.getVariable函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getVariable函數的具體用法?TypeScript getVariable怎麽用?TypeScript getVariable使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getVariable函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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:grawcho,項目名稱:vso-agent-tasks,代碼行數:15,代碼來源:provenance.ts

示例2: GetSessionId

 public static async GetSessionId(
     feedId: 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);
             return session.sessionId;
         } catch (error) {
             tl.warning(tl.loc("Warning_SessionCreationFailed", JSON.stringify(error)));
         }
     }
     return feedId;
 }
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:26,代碼來源:provenance.ts

示例3: _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:shubham90,項目名稱:vsts-tasks,代碼行數:8,代碼來源:ArtifactToolUtilities.ts

示例4: 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:grawcho,項目名稱:vso-agent-tasks,代碼行數:18,代碼來源:provenance.ts

示例5: _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:shubham90,項目名稱:vsts-tasks,代碼行數:11,代碼來源:twineauthenticatemain.ts

示例6: CreateBuildSessionRequest

    private static CreateBuildSessionRequest(feedId: string, buildId: string): SessionRequest {
        let buildData = {
            "System.CollectionId": tl.getVariable("System.CollectionId"),
            "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.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;
    }
開發者ID:grawcho,項目名稱:vso-agent-tasks,代碼行數:23,代碼來源:provenance.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:shubham90,項目名稱:vsts-tasks,代碼行數:17,代碼來源:universalmain.ts

示例8: GetSessionId

 public static async GetSessionId(
     feedId: string,
     protocol: string,
     baseUrl: string,
     handlers: VsoBaseInterfaces.IRequestHandler[],
     options: VsoBaseInterfaces.IRequestOptions): Promise<string> {
     
     // while this feature is in preview, it is enabled by the following variable
     const useSessionEnabled = tl.getVariable("Packaging.SavePublishMetadata");
     if (useSessionEnabled) {
         tl.debug("Creating provenance session");
         const prov = new ProvenanceApi(baseUrl, handlers, options);
         const sessionRequest = ProvenanceHelper.CreateSessionRequest(feedId);
         try {
             const session = await prov.createSession(sessionRequest, protocol);
             return session.sessionId;
         } catch (error) {
             tl.warning(tl.loc("Warning_SessionCreationFailed", JSON.stringify(error)));
         }
     }
     return feedId;
 }
開發者ID:grawcho,項目名稱:vso-agent-tasks,代碼行數:22,代碼來源:provenance.ts

示例9: 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", ",");

        // Local feeds
        if (feedIds)
        {
            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;
            }
            const globalWebApi = utils.getWebApi(packagingLocation, localAccessToken);
            for (const feedId of feedIds) {
                const feedUri = await utils.getPyPiSimpleApiFromFeedId(globalWebApi, feedId);
                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:shubham90,項目名稱:vsts-tasks,代碼行數:64,代碼來源:pipauthenticatemain.ts


注:本文中的vsts-task-lib.getVariable函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。