Search in sources :

Example 1 with BuildTypeChangeStatus

use of jetbrains.buildServer.vcs.BuildTypeChangeStatus in project teamcity-rest by JetBrains.

the class ChangeStatus method initCounters.

private void initCounters() {
    // This is heavily inspired by ChangeDetailsCalculator, but with some simplifications, so not reusing it here.
    SecurityContext context = myBeanContext.getSingletonService(SecurityContext.class);
    SUser self = (SUser) context.getAuthorityHolder().getAssociatedUser();
    myCriticalCollector = new BuildsCollector(myFields.getNestedField("criticalBuilds"));
    myCompilationErrorCollector = new BuildsCollector(myFields.getNestedField("compilationErrorBuilds"));
    myNewTestsFailedCollector = new BuildsCollector(myFields.getNestedField("newTestsFailedBuilds"));
    myNotCriticalCollector = new BuildsCollector(myFields.getNestedField("notCriticalBuilds"));
    final boolean includePersonalBuilds = self != null && StringUtil.isTrue(self.getPropertyValue(StandardProperties.SHOW_ALL_PERSONAL_BUILDS));
    for (BuildTypeChangeStatus status : myChangeStatus.getBuildTypesStatus().values()) {
        final SBuild firstBuild = status.getFirstBuild();
        if (firstBuild == null) {
            SQueuedBuild queued = status.getQueuedBuild();
            if (queued != null && (includePersonalBuilds || !queued.isPersonal())) {
                myQueuedBuildsCount++;
            }
            if (status.getQueuedBuild() == null) {
                myPendingCount++;
            }
            continue;
        }
        if (firstBuild.isPersonal() && !includePersonalBuilds) {
            continue;
        }
        if (firstBuild.getCanceledInfo() != null) {
            myCancelledCount++;
            continue;
        }
        if (firstBuild.isFinished()) {
            myFinishedBuildsCount++;
            if (status.isSuccessful()) {
                mySuccessfulBuildsCount++;
                // no need to count problems, as our build is green
                continue;
            }
        } else {
            myRunningBuildsCount++;
            Status runningBuildStatus = firstBuild.getBuildStatus();
            if (runningBuildStatus.isSuccessful()) {
                myRunningSuccessfullyCount++;
                // no need to count problems, as our build is green
                continue;
            }
        }
        myFailedBuildsCount++;
        String statusText = BuildStatusText.getBuildStatus(firstBuild, self);
        final BuildPromotionEx buildPromo = (BuildPromotionEx) firstBuild.getBuildPromotion();
        switch(statusText) {
            case BuildStatusText.NEW_TESTS_FAILED:
                myNewTestsFailedCollector.put(buildPromo);
                break;
            case BuildStatusText.CRITICAL_PROBLEM:
                myCriticalCollector.put(buildPromo);
                break;
            case BuildStatusText.COMPILATION_ERROR:
                myCompilationErrorCollector.put(buildPromo);
                break;
            default:
                myNotCriticalCollector.put(buildPromo);
        }
        for (BuildProblem problem : buildPromo.getBuildProblems()) {
            if (problem.isMutedInBuild())
                continue;
            if (problem.getBuildProblemData().getType().equals(BuildProblemData.TC_FAILED_TESTS_TYPE) || ErrorData.isSnapshotDependencyError(problem.getBuildProblemData().getType()))
                continue;
            myTotalProblemCount++;
        }
    }
}
Also used : Status(jetbrains.buildServer.messages.Status) BuildTypeChangeStatus(jetbrains.buildServer.vcs.BuildTypeChangeStatus) SUser(jetbrains.buildServer.users.SUser) BuildTypeChangeStatus(jetbrains.buildServer.vcs.BuildTypeChangeStatus) SecurityContext(jetbrains.buildServer.serverSide.auth.SecurityContext) BuildProblem(jetbrains.buildServer.serverSide.problems.BuildProblem)

Aggregations

Status (jetbrains.buildServer.messages.Status)1 SecurityContext (jetbrains.buildServer.serverSide.auth.SecurityContext)1 BuildProblem (jetbrains.buildServer.serverSide.problems.BuildProblem)1 SUser (jetbrains.buildServer.users.SUser)1 BuildTypeChangeStatus (jetbrains.buildServer.vcs.BuildTypeChangeStatus)1