Search in sources :

Example 16 with SVcsModification

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

the class ChangeStatusTest method testQueued.

public void testQueued() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    SQueuedBuild queuedBuild = build().in(buildConf).onModifications(m20).addToQueue();
    ChangeStatus status = new ChangeStatus(myFixture.getChangeStatusProvider().getMergedChangeStatus(m20), Fields.ALL_NESTED, getBeanContext(myFixture));
    queuedBuild.removeFromQueue(myUser, "comment");
    assertEquals(0, (int) status.getFinished());
    assertEquals(0, (int) status.getSuccessful());
    assertEquals(0, (int) status.getFailed());
    assertEquals(0, (int) status.getPendingBuildTypes());
    assertEquals(1, (int) status.getQueuedBuildsCount());
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.server.rest.model.change.ChangeStatus) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) SQueuedBuild(jetbrains.buildServer.serverSide.SQueuedBuild) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance)

Example 17 with SVcsModification

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

the class ChangeStatusTest method testSuccessfulFinished.

public void testSuccessfulFinished() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    build().in(buildConf).onModifications(m20).finish();
    ChangeStatus status = new ChangeStatus(myFixture.getChangeStatusProvider().getMergedChangeStatus(m20), Fields.ALL_NESTED, getBeanContext(myFixture));
    assertEquals(1, (int) status.getFinished());
    assertEquals(0, (int) status.getRunning());
    assertEquals(1, (int) status.getSuccessful());
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.server.rest.model.change.ChangeStatus) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance)

Example 18 with SVcsModification

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

the class ChangeStatusTest method testFailedRunning.

public void testFailedRunning() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    RunningBuildEx runningBuildEx = build().in(buildConf).onModifications(m20).run();
    ChangeStatus status = new ChangeStatus(myFixture.getChangeStatusProvider().getMergedChangeStatus(m20), Fields.ALL_NESTED, getBeanContext(myFixture));
    myFixture.finishBuild(runningBuildEx, true);
    assertEquals(0, (int) status.getFinished());
    assertEquals(0, (int) status.getSuccessful());
    assertEquals(0, (int) status.getFailed());
    assertEquals(1, (int) status.getRunning());
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) RunningBuildEx(jetbrains.buildServer.serverSide.RunningBuildEx) ChangeStatus(jetbrains.buildServer.server.rest.model.change.ChangeStatus) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance)

Example 19 with SVcsModification

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

the class IssueUsage method getChangesInternal.

public Changes getChangesInternal() {
    if (TeamCityProperties.getBooleanOrTrue("rest.beans.issueUsage.useStoredVcsModification")) {
        // todo: TeamCity API
        final IssueEx issueEx;
        issueEx = (IssueEx) myIssue;
        if (issueEx != null) {
            final SVcsModification relatedModification = (SVcsModification) issueEx.getRelatedModification();
            if (relatedModification != null) {
                return Changes.fromSVcsModifications(Collections.singletonList(relatedModification), null, myFields.getNestedField("changes", Fields.NONE, Fields.LONG), myBeanContext);
            }
        }
        return null;
    } else {
        // this is highly inefficient especially when serving /relatedIssues for a build with large number of changes
        final List<SVcsModification> relatedModifications = new ArrayList<SVcsModification>();
        final List<SVcsModification> vcsModifications = myBuild.getContainingChanges();
        for (SVcsModification vcsModification : vcsModifications) {
            if (vcsModification.getRelatedIssues().contains(myIssue)) {
                relatedModifications.add(vcsModification);
            }
        }
        return relatedModifications.isEmpty() ? null : Changes.fromSVcsModifications(relatedModifications, null, myFields.getNestedField("changes", Fields.NONE, Fields.LONG), myBeanContext);
    }
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) IssueEx(jetbrains.buildServer.issueTracker.IssueEx) ArrayList(java.util.ArrayList)

Example 20 with SVcsModification

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

the class ChangeRequest method getChangeFailedTestsTree.

/**
 *  Experimental, subject to change
 *  @since 2021.2
 */
@GET
@Path("/{changeLocator}/testsTree")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get failed tests tree for the matching change.", nickname = "getChangeFailedTestsTree", hidden = true)
public TestScopeTree getChangeFailedTestsTree(@ApiParam(format = LocatorName.CHANGE) @PathParam("changeLocator") String changeLocator, // todo: remove after ui migration
@QueryParam(TestScopeTreeCollector.SUBTREE_ROOT_ID) String subTreeRootId, @QueryParam("treeLocator") String treeLocatorText, @QueryParam("fields") String fields) {
    final SVcsModification change = myChangeFinder.getItem(changeLocator).getSVcsModification();
    ChangeStatusProvider myStatusProvider = myServiceLocator.getSingletonService(ChangeStatusProvider.class);
    ChangeStatus changeStatus = myStatusProvider.getMergedChangeStatus(change);
    Stream<BuildPromotion> firstBuildsPromotions = changeStatus.getBuildTypesStatusMap().values().stream().filter(Objects::nonNull);
    Locator treeLocator = Locator.createPotentiallyEmptyLocator(treeLocatorText);
    if (subTreeRootId != null) {
        treeLocator.setDimension(ProblemOccurrencesTreeCollector.SUB_TREE_ROOT_ID, subTreeRootId);
    }
    return new TestScopeTree(myTestScopeTreeCollector.getSlicedTreeFromBuildPromotions(firstBuildsPromotions, treeLocator), new Fields(fields), myBeanContext);
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.vcs.ChangeStatus) BuildPromotion(jetbrains.buildServer.serverSide.BuildPromotion) ServiceLocator(jetbrains.buildServer.ServiceLocator) Locator(jetbrains.buildServer.server.rest.data.Locator) Fields(jetbrains.buildServer.server.rest.model.Fields) TestScopeTree(jetbrains.buildServer.server.rest.model.problem.scope.TestScopeTree) Objects(java.util.Objects) ChangeStatusProvider(jetbrains.buildServer.vcs.ChangeStatusProvider) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

SVcsModification (jetbrains.buildServer.vcs.SVcsModification)24 VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)14 ChangeStatus (jetbrains.buildServer.server.rest.model.change.ChangeStatus)12 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)12 ApiOperation (io.swagger.annotations.ApiOperation)7 Fields (jetbrains.buildServer.server.rest.model.Fields)7 ChangeStatus (jetbrains.buildServer.vcs.ChangeStatus)7 ChangeStatusProvider (jetbrains.buildServer.vcs.ChangeStatusProvider)7 RunningBuildEx (jetbrains.buildServer.serverSide.RunningBuildEx)5 Test (org.testng.annotations.Test)5 BuildPromotion (jetbrains.buildServer.serverSide.BuildPromotion)4 ServiceLocator (jetbrains.buildServer.ServiceLocator)3 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)3 Locator (jetbrains.buildServer.server.rest.data.Locator)3 Objects (java.util.Objects)2 NotFoundException (jetbrains.buildServer.server.rest.errors.NotFoundException)2 BuildTypes (jetbrains.buildServer.server.rest.model.buildType.BuildTypes)2 SVcsRootImpl (jetbrains.buildServer.vcs.impl.SVcsRootImpl)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1