Search in sources :

Example 21 with SVcsModification

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

the class ChangeRequest method getDeployments.

/**
 * Experimental support only!
 */
@GET
@Path("/{changeLocator}/deployments")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get deployments with this change.", nickname = "getDeployments", hidden = true)
public Builds getDeployments(@ApiParam(format = LocatorName.CHANGE) @PathParam("changeLocator") String changeLocator, @QueryParam("fields") String fields) {
    final SVcsModification change = myChangeFinder.getItem(changeLocator).getSVcsModification();
    ChangeStatusProvider myStatusProvider = myServiceLocator.getSingletonService(ChangeStatusProvider.class);
    ChangeStatus changeStatus = myStatusProvider.getMergedChangeStatus(change);
    List<BuildPromotion> promotions = changeStatus.getDeploymentStatus().values().stream().filter(Objects::nonNull).collect(Collectors.toList());
    return Builds.createFromBuildPromotions(promotions, null, new Fields(fields), myBeanContext);
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.vcs.ChangeStatus) BuildPromotion(jetbrains.buildServer.serverSide.BuildPromotion) Fields(jetbrains.buildServer.server.rest.model.Fields) ChangeStatusProvider(jetbrains.buildServer.vcs.ChangeStatusProvider) ApiOperation(io.swagger.annotations.ApiOperation)

Example 22 with SVcsModification

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

the class ChangeRequest method getFilteredFiles.

/**
 * Experimental support only!
 * todo: Is it better to have this somewhere in Change model? E.g. fields=change(files($filterByBuildType(<buildTypeId>),name,...)))
 * @since 2021.1.1
 */
@GET
@Path("/{changeLocator}/files")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get files of the matching change filtered by relation to a given buildType.", nickname = "getFilteredFiles", hidden = true)
public FileChanges getFilteredFiles(@ApiParam(format = LocatorName.CHANGE) @PathParam("changeLocator") String changeLocatorString, @QueryParam("buildTypeId") String builtTypeId, @QueryParam("fields") String fields) {
    Locator changeLocator = Locator.createPotentiallyEmptyLocator(changeLocatorString);
    SVcsModification change = myChangeFinder.getItem(changeLocator.getStringRepresentation()).getSVcsModification();
    if (builtTypeId == null) {
        // Convenience method, same as Change.getFileChanges()
        ChangeStatusProvider myStatusProvider = myServiceLocator.getSingletonService(ChangeStatusProvider.class);
        ChangeStatus changeStatus = myStatusProvider.getMergedChangeStatus(change);
        return new FileChanges(new ArrayList<>(changeStatus.getMergedVcsModificationInfo().getChangedFiles()), new Fields(fields));
    }
    SBuildType buildType = myBuildTypeFinder.getItem(builtTypeId).getBuildType();
    if (buildType == null) {
        throw new NotFoundException("Build type not found.");
    }
    if (change.getRelatedConfigurations().stream().noneMatch(relatedBt -> relatedBt.getExternalId().equals(buildType.getExternalId()))) {
        ChangeStatusProvider myStatusProvider = myServiceLocator.getSingletonService(ChangeStatusProvider.class);
        ChangeStatus changeStatus = myStatusProvider.getMergedChangeStatus(change);
        return new FileChanges(new ArrayList<>(changeStatus.getMergedVcsModificationInfo().getChangedFiles()), new Fields(fields));
    }
    return new FileChanges(change.getFilteredChanges(buildType), new Fields(fields));
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.vcs.ChangeStatus) ServiceLocator(jetbrains.buildServer.ServiceLocator) Locator(jetbrains.buildServer.server.rest.data.Locator) Fields(jetbrains.buildServer.server.rest.model.Fields) SBuildType(jetbrains.buildServer.serverSide.SBuildType) NotFoundException(jetbrains.buildServer.server.rest.errors.NotFoundException) ChangeStatusProvider(jetbrains.buildServer.vcs.ChangeStatusProvider) ApiOperation(io.swagger.annotations.ApiOperation)

Example 23 with SVcsModification

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

the class BuildFinderByPromotionTest method testBuildsOrder.

@Test
public void testBuildsOrder() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    final SVcsRootImpl vcsRoot = myFixture.addVcsRoot("mock", "", buildConf);
    VcsRootInstance root1 = buildConf.getVcsRootInstanceForParent(vcsRoot);
    assert root1 != null;
    final SFinishedBuild build10 = build().in(buildConf).finish();
    myFixture.addModification(modification().in(root1).version("1"));
    final SVcsModification change20 = myFixture.addModification(modification().in(root1).version("2"));
    myFixture.addModification(modification().in(root1).version("3"));
    assertEquals(3, buildConf.getPendingChanges().size());
    final SFinishedBuild build20 = build().in(buildConf).finish();
    final SFinishedBuild build30 = build().in(buildConf).onModifications(change20).finish();
    checkBuilds(null, build30, build20, build10);
    checkBuilds("buildType:(id:" + buildConf.getExternalId() + ")", build30, build20, build10);
    checkBuilds("sinceBuild:(id:" + build20.getBuildId() + ")", build30);
}
Also used : SVcsRootImpl(jetbrains.buildServer.vcs.impl.SVcsRootImpl) SVcsModification(jetbrains.buildServer.vcs.SVcsModification) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) Test(org.testng.annotations.Test)

Example 24 with SVcsModification

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

the class BuildFinderTest method testBuildsOrder.

@Test
public void testBuildsOrder() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    final SVcsRootImpl vcsRoot = myFixture.addVcsRoot("mock", "", buildConf);
    VcsRootInstance root1 = buildConf.getVcsRootInstanceForParent(vcsRoot);
    assert root1 != null;
    final SFinishedBuild build10 = build().in(buildConf).finish();
    myFixture.addModification(modification().in(root1).version("1"));
    final SVcsModification change20 = myFixture.addModification(modification().in(root1).version("2"));
    myFixture.addModification(modification().in(root1).version("3"));
    assertEquals(3, buildConf.getPendingChanges().size());
    final SFinishedBuild build20 = build().in(buildConf).finish();
    final SFinishedBuild build30 = build().in(buildConf).onModifications(change20).finish();
    checkBuilds(null, build30, build20, build10);
    checkBuilds("buildType:(id:" + buildConf.getExternalId() + ")", build30, build20, build10);
    checkBuilds("sinceBuild:(id:" + build20.getBuildId() + ")", build30);
}
Also used : SVcsRootImpl(jetbrains.buildServer.vcs.impl.SVcsRootImpl) SVcsModification(jetbrains.buildServer.vcs.SVcsModification) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) Test(org.testng.annotations.Test)

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