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


TypeScript IBuildApi.getChangesBetweenBuilds方法代碼示例

本文整理匯總了TypeScript中vso-node-api/BuildApi.IBuildApi.getChangesBetweenBuilds方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IBuildApi.getChangesBetweenBuilds方法的具體用法?TypeScript IBuildApi.getChangesBetweenBuilds怎麽用?TypeScript IBuildApi.getChangesBetweenBuilds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vso-node-api/BuildApi.IBuildApi的用法示例。


在下文中一共展示了IBuildApi.getChangesBetweenBuilds方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: parseInt

    var promise = new Promise<void>(async (resolve, reject) => {

        try {
            agentApi.logDebug("Starting Tag XplatGenerateReleaseNotes task");

            let tpcUri = tl.getVariable("System.TeamFoundationCollectionUri");
            let teamProject = tl.getVariable("System.TeamProject");
            let releaseId: number = parseInt(tl.getVariable("Release.ReleaseId"));
            let releaseDefinitionId: number = parseInt(tl.getVariable("Release.DefinitionId"));

            // Inputs
            let environmentName: string = (tl.getInput("overrideStageName") || tl.getVariable("Release_EnvironmentName")).toLowerCase();
            var templateLocation = tl.getInput("templateLocation", true);
            var templateFile = tl.getInput("templatefile");
            var inlineTemplate = tl.getInput("inlinetemplate");
            var outputfile = tl.getInput("outputfile", true);
            var outputVariableName = tl.getInput("outputVariableName");
            var emptyDataset = tl.getInput("emptySetText");

            let credentialHandler: vstsInterfaces.IRequestHandler = util.getCredentialHandler();
            let vsts = new webApi.WebApi(tpcUri, credentialHandler);
            var releaseApi: IReleaseApi = await vsts.getReleaseApi();
            var buildApi: IBuildApi = await vsts.getBuildApi();

            agentApi.logInfo("Getting the current release details");
            var currentRelease = await releaseApi.getRelease(teamProject, releaseId);

            if (!currentRelease) {
                reject(`Unable to locate the current release with id ${releaseId}`);
                return;
            }

            var environmentId = util.getReleaseDefinitionId(currentRelease.environments, environmentName);

            let mostRecentSuccessfulDeployment = await util.getMostRecentSuccessfulDeployment(releaseApi, teamProject, releaseDefinitionId, environmentId);
            let mostRecentSuccessfulDeploymentRelease: Release;

            agentApi.logInfo(`Getting all artifacts in the current release...`);
            var arifactsInThisRelease = util.getSimpleArtifactArray(currentRelease.artifacts);
            agentApi.logInfo(`Found ${arifactsInThisRelease.length}`);

            let arifactsInMostRecentRelease: util.SimpleArtifact[] = [];
            var mostRecentSuccessfulDeploymentName: string = "";
            if (mostRecentSuccessfulDeployment) {
                // Get the release that the deployment was a part of - This is required for the templating.
                mostRecentSuccessfulDeploymentRelease = await releaseApi.getRelease(teamProject, mostRecentSuccessfulDeployment.release.id);
                agentApi.logInfo(`Getting all artifacts in the most recent successful release [${mostRecentSuccessfulDeployment.release.name}]...`);
                arifactsInMostRecentRelease = util.getSimpleArtifactArray(mostRecentSuccessfulDeployment.release.artifacts);
                mostRecentSuccessfulDeploymentName = mostRecentSuccessfulDeployment.release.name;
                agentApi.logInfo(`Found ${arifactsInMostRecentRelease.length}`);
            } else {
                agentApi.logInfo(`Skipping fetching artifact in the most recent successful release as there isn't one.`);
                // we need to set the last successful as the current release to templates can get some data
                mostRecentSuccessfulDeploymentRelease = currentRelease;
            }

            var globalCommits: Change[] = [];
            var globalWorkItems: ResourceRef[] = [];

            for (var artifactInThisRelease of arifactsInThisRelease) {
                agentApi.logInfo(`Looking at artifact [${artifactInThisRelease.artifactAlias}]`);
                agentApi.logInfo(`Build Number: [${artifactInThisRelease.buildNumber}]`);

                var buildNumberFromMostRecentBuild = null;

                if (arifactsInMostRecentRelease.length > 0) {
                    agentApi.logInfo(`Looking for the [${artifactInThisRelease.artifactAlias}] in the most recent successful release [${mostRecentSuccessfulDeploymentName}]`);
                    for (var artifactInMostRecentRelease of arifactsInMostRecentRelease) {
                        if (artifactInThisRelease.artifactAlias.toLowerCase() === artifactInMostRecentRelease.artifactAlias.toLowerCase()) {
                            agentApi.logInfo(`Found artifact [${artifactInThisRelease.artifactAlias}] with build number [${artifactInThisRelease.buildNumber}] in release [${mostRecentSuccessfulDeploymentName}]`);

                            // Only get the commits and workitems if the builds are different
                            if (artifactInMostRecentRelease.buildNumber.toLowerCase() !== artifactInThisRelease.buildNumber.toLowerCase()) {
                                agentApi.logInfo(`Checking what commits and workitems have changed from [${artifactInMostRecentRelease.buildNumber}] => [${artifactInThisRelease.buildNumber}]`);

                                var commits = await buildApi.getChangesBetweenBuilds(teamProject, parseInt(artifactInMostRecentRelease.buildId),  parseInt(artifactInThisRelease.buildId), 5000);

                                var workitems = await buildApi.getWorkItemsBetweenBuilds(teamProject, parseInt(artifactInMostRecentRelease.buildId),  parseInt(artifactInThisRelease.buildId), 5000);

                                var commitCount: number = 0;
                                var workItemCount: number = 0;

                                if (commits) {
                                    commitCount = commits.length;
                                    globalCommits = globalCommits.concat(commits);
                                }

                                if (workitems) {
                                    workItemCount = workitems.length;
                                    globalWorkItems = globalWorkItems.concat(workitems);
                                }

                                agentApi.logInfo(`Detected ${commitCount} commits/changesets and ${workItemCount} workitems between the builds.`);
                            } else {
                                agentApi.logInfo(`Build for artifact [${artifactInThisRelease.artifactAlias}] has not changed.  Nothing to do`);
                            }
                        }
                    }
                }
                agentApi.logInfo(``);
//.........這裏部分代碼省略.........
開發者ID:Edgixshua,項目名稱:vNextBuild,代碼行數:101,代碼來源:GenerateReleaseNotes.ts


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