Search in sources :

Example 6 with BuildPromotion

use of jetbrains.buildServer.serverSide.BuildPromotion 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 7 with BuildPromotion

use of jetbrains.buildServer.serverSide.BuildPromotion 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 8 with BuildPromotion

use of jetbrains.buildServer.serverSide.BuildPromotion in project teamcity-rest by JetBrains.

the class DownloadedArtifacts method getFilteredInfo.

@NotNull
private Map<SBuild, List<ArtifactInfo>> getFilteredInfo() {
    Map<SBuild, List<ArtifactInfo>> result = new HashMap<>();
    String buildLocatorText = myFields.getLocator();
    FilterConditionChecker<BuildPromotion> buildFilter;
    if (StringUtil.isNotEmpty(buildLocatorText)) {
        Locator buildLocator = Locator.locator(buildLocatorText);
        buildFilter = myBeanContext.getSingletonService(BuildPromotionFinder.class).getFilter(buildLocator);
        buildLocator.checkLocatorFullyProcessed();
    } else {
        buildFilter = b -> true;
    }
    for (Map.Entry<Build, List<ArtifactInfo>> buildArtifacts : myArtifacts.getArtifacts().entrySet()) {
        SBuild build = (SBuild) buildArtifacts.getKey();
        if (!buildFilter.isIncluded(build.getBuildPromotion())) {
            continue;
        }
        result.put(build, buildArtifacts.getValue());
    }
    return result;
}
Also used : SBuild(jetbrains.buildServer.serverSide.SBuild) BuildPromotion(jetbrains.buildServer.serverSide.BuildPromotion) Locator(jetbrains.buildServer.server.rest.data.Locator) HashMap(java.util.HashMap) Build(jetbrains.buildServer.Build) SBuild(jetbrains.buildServer.serverSide.SBuild) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with BuildPromotion

use of jetbrains.buildServer.serverSide.BuildPromotion in project teamcity-rest by JetBrains.

the class Branch method getBuilds.

/**
 * Experimental support only
 */
@XmlElement(name = "builds")
public Builds getBuilds() {
    return ValueWithDefault.decideDefault(myFields.isIncluded("builds", false), () -> {
        String buildsHref = null;
        PagedSearchResult<BuildPromotion> builds = null;
        final Fields buildsFields = myFields.getNestedField("builds");
        final String buildsLocator = buildsFields.getLocator();
        if (buildsLocator != null) {
            builds = myBranch.getBuilds(buildsFields.getLocator());
            buildsHref = BuildRequest.getBuildsHref(myBranch, buildsLocator);
        } else {
            buildsHref = BuildRequest.getBuildsHref(myBranch, null);
        }
        if (builds == null && buildsHref == null)
            return null;
        return Builds.createFromBuildPromotions(builds == null ? null : builds.myEntries, buildsHref == null ? null : new PagerData(buildsHref), buildsFields, myBeanContext);
    });
}
Also used : BuildPromotion(jetbrains.buildServer.serverSide.BuildPromotion) Fields(jetbrains.buildServer.server.rest.model.Fields) PagerData(jetbrains.buildServer.server.rest.model.PagerData) XmlElement(javax.xml.bind.annotation.XmlElement)

Example 10 with BuildPromotion

use of jetbrains.buildServer.serverSide.BuildPromotion 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

BuildPromotion (jetbrains.buildServer.serverSide.BuildPromotion)11 ApiOperation (io.swagger.annotations.ApiOperation)5 Fields (jetbrains.buildServer.server.rest.model.Fields)5 Locator (jetbrains.buildServer.server.rest.data.Locator)4 ChangeStatus (jetbrains.buildServer.vcs.ChangeStatus)4 ChangeStatusProvider (jetbrains.buildServer.vcs.ChangeStatusProvider)4 SVcsModification (jetbrains.buildServer.vcs.SVcsModification)4 NotNull (org.jetbrains.annotations.NotNull)4 Objects (java.util.Objects)2 ServiceLocator (jetbrains.buildServer.ServiceLocator)2 PagerData (jetbrains.buildServer.server.rest.model.PagerData)2 SBuild (jetbrains.buildServer.serverSide.SBuild)2 java.util (java.util)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 XmlElement (javax.xml.bind.annotation.XmlElement)1 Build (jetbrains.buildServer.Build)1