Search in sources :

Example 1 with ChangeStatusProvider

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

the class ChangeRequest method getChangeFirstBuilds.

/**
 * Experimental support only!
 */
@GET
@Path("/{changeLocator}/firstBuilds")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get first builds of the matching change.", nickname = "getChangeFirstBuilds", hidden = true)
public Builds getChangeFirstBuilds(@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> firstBuildsPromotions = changeStatus.getBuildTypesStatusMap().values().stream().filter(Objects::nonNull).collect(Collectors.toList());
    return Builds.createFromBuildPromotions(firstBuildsPromotions, 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 2 with ChangeStatusProvider

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

the class ChangeRequest method getDeploymentConfigurations.

/**
 * Experimental support only!
 */
@GET
@Path("/{changeLocator}/deploymentConfigurations")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get build configurations where this change could potentially be deployed.", nickname = "getDeploymentConfigurations", hidden = true)
public BuildTypes getDeploymentConfigurations(@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);
    return new BuildTypes(BuildTypes.fromBuildTypes(changeStatus.getDeploymentStatus().keySet()), null, new Fields(fields), myBeanContext);
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.vcs.ChangeStatus) Fields(jetbrains.buildServer.server.rest.model.Fields) BuildTypes(jetbrains.buildServer.server.rest.model.buildType.BuildTypes) ChangeStatusProvider(jetbrains.buildServer.vcs.ChangeStatusProvider) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with ChangeStatusProvider

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

the class ChangeRequest method getRelatedBuildTypes.

/**
 * Experimental support only!
 */
@GET
@Path("/{changeLocator}/buildTypes")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get build configurations related to the matching change.", nickname = "getRelatedBuildTypes", hidden = true)
public BuildTypes getRelatedBuildTypes(@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);
    return new BuildTypes(BuildTypes.fromBuildTypes(changeStatus.getRelatedConfigurations()), null, new Fields(fields), myBeanContext);
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.vcs.ChangeStatus) Fields(jetbrains.buildServer.server.rest.model.Fields) BuildTypes(jetbrains.buildServer.server.rest.model.buildType.BuildTypes) ChangeStatusProvider(jetbrains.buildServer.vcs.ChangeStatusProvider) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with ChangeStatusProvider

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

the class ChangeRequest method getChangeProblemsTree.

/**
 *  Experimental, subject to change
 *  @since 2021.2
 */
@GET
@Path("/{changeLocator}/problemsTree")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get problems tree for the matching change.", nickname = "getChangeProblemsTree", hidden = true)
public ProblemOccurrencesTree getChangeProblemsTree(@ApiParam(format = LocatorName.CHANGE) @PathParam("changeLocator") String changeLocator, // todo: remove after ui migration
@QueryParam(ProblemOccurrencesTreeCollector.SUB_TREE_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 ProblemOccurrencesTree(myProblemOccurrencesTreeCollector.getTreeFromBuildPromotions(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) Objects(java.util.Objects) ProblemOccurrencesTree(jetbrains.buildServer.server.rest.model.problem.scope.ProblemOccurrencesTree) ChangeStatusProvider(jetbrains.buildServer.vcs.ChangeStatusProvider) ApiOperation(io.swagger.annotations.ApiOperation)

Example 5 with ChangeStatusProvider

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

the class Change method getStatus.

@XmlElement(name = "status")
public ChangeStatus getStatus() {
    return ValueWithDefault.decideDefault(myFields.isIncluded("status", false, false), () -> {
        ChangeStatusProvider statusProvider = myBeanContext.getSingletonService(ChangeStatusProvider.class);
        jetbrains.buildServer.vcs.ChangeStatus mergedStatus = statusProvider.getMergedChangeStatus(myModification);
        return new ChangeStatus(mergedStatus, myFields.getNestedField("status"), myBeanContext);
    });
}
Also used : ChangeStatusProvider(jetbrains.buildServer.vcs.ChangeStatusProvider) XmlElement(javax.xml.bind.annotation.XmlElement)

Aggregations

ChangeStatusProvider (jetbrains.buildServer.vcs.ChangeStatusProvider)8 ApiOperation (io.swagger.annotations.ApiOperation)7 Fields (jetbrains.buildServer.server.rest.model.Fields)7 ChangeStatus (jetbrains.buildServer.vcs.ChangeStatus)7 SVcsModification (jetbrains.buildServer.vcs.SVcsModification)7 BuildPromotion (jetbrains.buildServer.serverSide.BuildPromotion)4 ServiceLocator (jetbrains.buildServer.ServiceLocator)3 Locator (jetbrains.buildServer.server.rest.data.Locator)3 Objects (java.util.Objects)2 BuildTypes (jetbrains.buildServer.server.rest.model.buildType.BuildTypes)2 XmlElement (javax.xml.bind.annotation.XmlElement)1 NotFoundException (jetbrains.buildServer.server.rest.errors.NotFoundException)1 ProblemOccurrencesTree (jetbrains.buildServer.server.rest.model.problem.scope.ProblemOccurrencesTree)1 TestScopeTree (jetbrains.buildServer.server.rest.model.problem.scope.TestScopeTree)1 SBuildType (jetbrains.buildServer.serverSide.SBuildType)1