use of jetbrains.buildServer.vcs.ChangeStatusProvider 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);
}
use of jetbrains.buildServer.vcs.ChangeStatusProvider 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);
}
use of jetbrains.buildServer.vcs.ChangeStatusProvider 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));
}
Aggregations