• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: publishPackageUsingArtifactTool

function publishPackageUsingArtifactTool(
    publishDir: string,
    options: artifactToolRunner.IArtifactToolOptions,
    execOptions: IExecOptions) {
    const command = new Array<string>();
    command.push("universal", "publish",
        "--feed", options.feedId,
        "--service", options.accountUrl,
        "--package-name", options.packageName,
        "--package-version", options.packageVersion,
        "--path", publishDir,
        "--patvar", "UNIVERSAL_PUBLISH_PAT",
        "--verbosity", tl.getInput("verbosity"),
        "--description", tl.getInput("packagePublishDescription"));

    console.log(tl.loc("Info_Publishing", options.packageName, options.packageVersion, options.feedId));
    const execResult: IExecSyncResult = artifactToolRunner.runArtifactTool(
        options.artifactToolPath,
        command,
        execOptions);

    if (execResult.code === 0) {
        return;
    }

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


示例2: 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


示例3: main

async function main(): Promise<void> {
    tl.setResourcePath(path.join(__dirname, "task.json"));
    try {
        // Local feeds
        const internalFeeds = await auth.getInternalAuthInfoArray("feedList");
        // external service endpoints
        const externalEndpoints = await auth.getExternalAuthInfoArray("externalSources");
        // combination of both internal and external
        const newEndpointsToAdd = internalFeeds.concat(externalEndpoints);

        let pypircPath = utils.getPypircPath();

        // Case when there are multiple twine auth tasks in a build
        if (tl.exist(pypircPath)) {
            // merge two tasks
            tl.debug(tl.loc("Info_StartParsingExistingPypircFile", pypircPath));
            let fileContent = ini.parse(fs.readFileSync(pypircPath, "utf-8"));

            // Adding new endpoints to already existing .pypirc file.
            for (const entry of newEndpointsToAdd){
                if (entry.packageSource.feedName in fileContent){
                    // Hard fail if there is a name collision from service endpoint
                    throw new Error(tl.loc("Error_DuplicateEntryForExternalFeed",
                    entry.packageSource.feedName));
                }

                fileContent[entry.packageSource.feedName] = new Repository(
                    entry.packageSource.feedUri,
                    entry.username,
                    entry.password);
                fileContent["distutils"]["index-servers"] += " " + entry.packageSource.feedName;
            }

            let encodedStr = ini.encode(fileContent);
            fs.writeFileSync(pypircPath, encodedStr);
        }
        else {
            // create new
            fs.writeFileSync(pypircPath, formPypircFormatFromData(newEndpointsToAdd));
            tl.setVariable("PYPIRC_PATH", pypircPath, false);
            tl.debug(tl.loc("VariableSetForPypirc", pypircPath));
        }

        // Configuring the pypirc file
        console.log(tl.loc("Info_SuccessAddingAuth", internalFeeds.length, externalEndpoints.length));
    }
    catch (error) {
        tl.error(error);
        tl.setResult(tl.TaskResult.Failed, tl.loc("FailedToAddAuthentication"));
        return;
    } finally{
        _logTwineAuthStartupVariables();
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:54,代码来源:twineauthenticatemain.ts


示例4: 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


示例5: 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


示例6: downloadUniversalPackage

export async function downloadUniversalPackage(
    downloadPath: string,
    feedId: string,
    packageId: string,
    version: string,
    filterPattern: string
): Promise<void> {
    try {
        const accessToken = pkgLocationUtils.getSystemAccessToken();
        let serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
        const blobUri = await pkgLocationUtils.getBlobstoreUriFromBaseServiceUri(serviceUri, accessToken);

        // Finding the artifact tool directory
        var artifactToolPath = await artifactToolUtilities.getArtifactToolFromService(
            blobUri,
            accessToken,
            "artifacttool"
        );

        const feedUri = await pkgLocationUtils.getFeedUriFromBaseServiceUri(serviceUri, accessToken);
        let packageName: string = await artifactToolUtilities.getPackageNameFromId(
            feedUri,
            accessToken,
            feedId,
            packageId
        );

        tl.debug(tl.loc("Info_UsingArtifactToolDownload"));

        const downloadOptions = {
            artifactToolPath,
            feedId,
            accountUrl: serviceUri,
            packageName,
            packageVersion: version
        } as artifactToolRunner.IArtifactToolOptions;

        let toolRunnerOptions = artifactToolRunner.getOptions();
        toolRunnerOptions.env.UNIVERSAL_DOWNLOAD_PAT = accessToken;
        downloadPackageUsingArtifactTool(downloadPath, downloadOptions, toolRunnerOptions, filterPattern);
    } catch (error) {
        tl.setResult(tl.TaskResult.Failed, error.message);
        return;
    } finally {
        _logUniversalStartupVariables({
            ArtifactToolPath: artifactToolPath,
            PackageType: "Universal",
            FeedId : feedId,
            PackageId: packageId,
            Version: version,
            IsTriggeringArtifact: tl.getInput("isTriggeringArtifact")
        });
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:54,代码来源:universal.ts


示例7: 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


示例8: formPypircFormatFromData

// only used for new file writes.
function formPypircFormatFromData(authInfo: auth.AuthInfo[]): string{
    let ent : {} = {};

    let header = util.format("[distutils]%sindex-servers=", os.EOL);

    for(let entry of authInfo) {
        if (entry.packageSource.feedName in ent){
            throw new Error(tl.loc("Error_DuplicateEntryForExternalFeed",
                    entry.packageSource.feedName));
        }
        header += util.format("%s ", entry.packageSource.feedName);
        ent[entry.packageSource.feedName] = new Repository(entry.packageSource.feedUri, entry.username, entry.password);
    }
    let encodedStr = ini.encode(ent);

    header = header + os.EOL + encodedStr;
    return header;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:19,代码来源:twineauthenticatemain.ts


示例9: logSummary

    public logSummary(): void {
        var allTickets = this.store.getTickets();
        var fileTickets = allTickets.filter(x => x.artifactItem.itemType == ItemType.File);

        var finishedItems = fileTickets.filter(x => x.state == TicketState.Processed || x.state == TicketState.Skipped || x.state == TicketState.Failed);
        var processedItems = fileTickets.filter(x => x.state == TicketState.Processed);
        var skippedItems = fileTickets.filter(x => x.state == TicketState.Skipped);
        var failedItems = fileTickets.filter(x => x.state == TicketState.Failed);

        var downloadSizeInBytes = 0;
        var fileSizeInBytes = 0;

        for (var ticket of fileTickets) {
            downloadSizeInBytes += ticket.downloadSizeInBytes;
            fileSizeInBytes += ticket.fileSizeInBytes;
        }

        var downloadSizeInMB = (downloadSizeInBytes / (1024 * 1024));

        var endTime = new Date();
        var downloadTime = (endTime.valueOf() - this.startTime.valueOf()) / 1000;
        console.log(
            tl.loc("DownloadSummary", 
                    fileTickets.length, 
                    processedItems.length, 
                    skippedItems.length, 
                    failedItems.length, 
                    downloadTime, 
                    (downloadSizeInMB > 1 ? downloadSizeInMB.toFixed(3) + "MB" : downloadSizeInBytes + "Bytes")));

        ci.publishEvent('performance',
            {
                location: this.store.getRootLocation(),
                total: allTickets.length,
                files: fileTickets.length,
                processed: processedItems.length,
                skipped: skippedItems.length,
                failed: failedItems.length,
                downloadTimeInSeconds: downloadTime,
                downloadSizeInBytes: downloadSizeInBytes,
                fileSizeInBytes: fileSizeInBytes
            });

        if (Logger.verbose) {
            tl.debug("Summary:");
            var pathLengths = finishedItems.map(x => x.artifactItem.path.length);
            var maxPathLength = pathLengths.reduce((a, b) => a > b ? a : b, 1);
            var fileHeader = this.padText("File", maxPathLength);
            var startTimeHeader = this.padText("Start Time", 25);
            var finishTimeHeader = this.padText("Finish Time", 25);
            var durationHeader = this.padText("Duration", 10);
            var stateHeader = this.padText("STATE", 10);

            tl.debug(this.padText("", maxPathLength + 25 + 25 + 10 + 10 + 15, '-'))
            tl.debug(`| ${fileHeader} | ${startTimeHeader} | ${finishTimeHeader} | ${durationHeader} | ${stateHeader}|`)
            tl.debug(this.padText("", maxPathLength + 25 + 25 + 10 + 10 + 15, '-'))
            fileTickets.forEach(ticket => {
                var duration = (ticket.finishTime.valueOf() - ticket.startTime.valueOf()) / 1000 + " secs";
                tl.debug("| " + this.padText(ticket.artifactItem.path, maxPathLength) + " | " + this.padText(ticket.startTime.toISOString(), 25) + " | " + this.padText(ticket.finishTime.toISOString(), 25) + " | " + this.padText(duration, 10) + " | " + this.padText(ticket.state.toString().toUpperCase(), 10) + "|");
                tl.debug(this.padText("", maxPathLength + 25 + 25 + 10 + 10 + 15, '-'))
            });
        }
    }
开发者ID:Microsoft,项目名称:vsts-rm-extensions,代码行数:63,代码来源:logger.ts


示例10: run

export async function run(artifactToolPath: string): Promise<void> {
    const buildIdentityDisplayName: string = null;
    const buildIdentityAccount: string = null;
    try {
        // Get directory to publish
        const publishDir: string = tl.getInput("publishDirectory");
        if (publishDir.length < 1)
        {
            tl.debug(tl.loc("Info_PublishDirectoryNotFound"));
            return;
        }

        let serviceUri: string;
        let feedId: string;
        let packageName: string;
        let version: string;
        let accessToken: string;
        let feedUri: string;
        const publishedPackageVar: string = tl.getInput("publishedPackageVar");
        const versionRadio = tl.getInput("versionPublishSelector");

        // Feed Auth
        let feedType = tl.getInput("internalOrExternalPublish") || "internal";

        const normalizedFeedType = ["internal", "external"].find((x) =>
            feedType.toUpperCase() === x.toUpperCase());
        if (!normalizedFeedType) {
            throw new Error(tl.loc("UnknownFeedType", feedType));
        }
        feedType = normalizedFeedType;

        let internalAuthInfo: auth.InternalAuthInfo;

        const toolRunnerOptions = artifactToolRunner.getOptions();

        let sessionId: string;

        if (feedType === "internal")
        {
            // getting inputs
            serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);

            packageName = tl.getInput("packageListPublish");
            feedId = tl.getInput("feedListPublish");

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

            toolRunnerOptions.env.UNIVERSAL_PUBLISH_PAT = internalAuthInfo.accessToken;

            let packagingLocation: string;
            try {
                // This call is to get the packaging URI(abc.pkgs.vs.com) which is same for all protocols.
                packagingLocation = await pkgLocationUtils.getNuGetUriFromBaseServiceUri(
                    serviceUri,
                    accessToken);
            } catch (error) {
                tl.debug(JSON.stringify(error));
                packagingLocation = serviceUri;
            }

            const pkgConn = pkgLocationUtils.getWebApiWithProxy(packagingLocation, accessToken);
            sessionId = await ProvenanceHelper.GetSessionId(
                feedId,
                null,
                "upack", /* must match protocol name on the server */
                pkgConn.serverUrl,
                [pkgConn.authHandler],
                pkgConn.options);
        }
        else {
            const externalAuthInfo = auth.GetExternalAuthInfo("externalEndpoints");
            if (!externalAuthInfo)
            {
                tl.setResult(tl.TaskResult.Failed, tl.loc("Error_NoSourceSpecifiedForPublish"));
                return;
            }

            serviceUri = externalAuthInfo.packageSource.accountUrl;

            feedId = tl.getInput("feedPublishExternal");
            packageName = tl.getInput("packagePublishExternal");

            // Assuming only auth via PAT works for now
            accessToken = (externalAuthInfo as auth.TokenExternalAuthInfo).token;
            toolRunnerOptions.env.UNIVERSAL_PUBLISH_PAT = accessToken;
        }

        if (versionRadio === "custom"){
            version = tl.getInput("versionPublish");
        }
        else{
            feedUri = await pkgLocationUtils.getFeedUriFromBaseServiceUri(serviceUri, accessToken);

            const highestVersion = await artifactToolUtilities.getHighestPackageVersionFromFeed(
                feedUri,
                accessToken,
                feedId,
                packageName);
//.........这里部分代码省略.........
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:101,代码来源:universalpublish.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap