Search in sources :

Example 1 with BuildPromotion

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

the class ProblemFinder method getProblemsByBuilds.

@NotNull
private Set<ProblemWrapper> getProblemsByBuilds(@NotNull final String buildLocator) {
    LinkedHashSet<ProblemWrapper> result = new LinkedHashSet<>();
    List<BuildPromotion> builds = myBuildPromotionFinder.getItems(buildLocator).myEntries;
    for (BuildPromotion build : builds) {
        result.addAll(CollectionsUtil.convertCollection(ProblemOccurrenceFinder.getProblemOccurrences(build), new Converter<ProblemWrapper, BuildProblem>() {

            @Override
            public ProblemWrapper createFrom(@NotNull final BuildProblem buildProblem) {
                return new ProblemWrapper(buildProblem.getId(), buildProblem.getBuildProblemData(), myServiceLocator);
            }
        }));
    }
    return result;
}
Also used : BuildPromotion(jetbrains.buildServer.serverSide.BuildPromotion) Converter(jetbrains.buildServer.util.Converter) BuildProblem(jetbrains.buildServer.serverSide.problems.BuildProblem) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with BuildPromotion

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

the class TestScopeTreeCollector method getSlicedTreeFromBuildPromotions.

@NotNull
public List<ScopeTree.Node<STestRun, TestCountersData>> getSlicedTreeFromBuildPromotions(@NotNull Stream<BuildPromotion> promotions, @NotNull Locator treeLocator) {
    treeLocator.addSupportedDimensions(NEW_FAILURE, SUBTREE_ROOT_ID);
    final String testRunsLocator = "build:%d,status:failure,muted:false,ignored:false" + (treeLocator.isAnyPresent(NEW_FAILURE) ? ",newFailure:" + treeLocator.getSingleDimensionValue(NEW_FAILURE) : "");
    Stream<STestRun> testRunStream = promotions.filter(promotion -> promotion.getAssociatedBuildId() != null).flatMap(promotion -> myTestOccurrenceFinder.getItems(String.format(testRunsLocator, promotion.getAssociatedBuildId())).myEntries.stream());
    Stream<TestScope> scopeStream = myScopeCollector.groupByClass(testRunStream, new TestScopeFilterImpl(Collections.emptyList(), ""));
    scopeStream = myScopeCollector.splitByBuildType(scopeStream);
    List<TestScope> scopes = scopeStream.collect(Collectors.toList());
    ScopeTree<STestRun, TestCountersData> tree = new ScopeTree<STestRun, TestCountersData>(TestScopeInfo.ROOT, new TestCountersData(), scopes);
    if (treeLocator.isAnyPresent(SUBTREE_ROOT_ID)) {
        String subTreeRootId = treeLocator.getSingleDimensionValue(SUBTREE_ROOT_ID);
        treeLocator.checkLocatorFullyProcessed();
        // noinspection ConstantConditions
        return tree.getFullNodeAndSlicedOrderedSubtree(subTreeRootId, DEFAULT_MAX_CHILDREN, STestRun.NEW_FIRST_NAME_COMPARATOR, SUPPORTED_ORDERS.getComparator(DEFAULT_NODE_ORDER_BY_NEW_FAILED_COUNT));
    }
    treeLocator.checkLocatorFullyProcessed();
    return tree.getSlicedOrderedTree(DEFAULT_MAX_CHILDREN, STestRun.NEW_FIRST_NAME_COMPARATOR, SUPPORTED_ORDERS.getComparator(DEFAULT_NODE_ORDER_BY_NEW_FAILED_COUNT));
}
Also used : LocatorProcessException(jetbrains.buildServer.server.rest.errors.LocatorProcessException) java.util(java.util) BuildPromotion(jetbrains.buildServer.serverSide.BuildPromotion) STestRun(jetbrains.buildServer.serverSide.STestRun) Locator(jetbrains.buildServer.server.rest.data.Locator) Collectors(java.util.stream.Collectors) TestCountersData(jetbrains.buildServer.server.rest.data.problem.TestCountersData) jetbrains.buildServer.server.rest.data.problem.tree(jetbrains.buildServer.server.rest.data.problem.tree) Stream(java.util.stream.Stream) Orders(jetbrains.buildServer.server.rest.data.problem.Orders) TestOccurrenceFinder(jetbrains.buildServer.server.rest.data.problem.TestOccurrenceFinder) NotNull(org.jetbrains.annotations.NotNull) PagerData(jetbrains.buildServer.server.rest.model.PagerData) STestRun(jetbrains.buildServer.serverSide.STestRun) TestCountersData(jetbrains.buildServer.server.rest.data.problem.TestCountersData) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with BuildPromotion

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

the class BuildFinderTestBase method checkBuild.

protected void checkBuild(final SBuildType buildType, final String locator, @NotNull BuildPromotion buildPromotion) {
    SBuild build = buildPromotion.getAssociatedBuild();
    if (build != null) {
        // checking for build
        SBuild result = myBuildFinder.getBuild(buildType, locator);
        if (!build.equals(result)) {
            fail("While searching for single build with locator \"" + locator + "\"\n" + "Expected: " + LogUtil.describeInDetail(build) + "\n" + "Actual: " + LogUtil.describeInDetail(result));
        }
    }
    // checking for build promotion
    BuildPromotion result1 = myBuildFinder.getBuildPromotion(buildType, locator);
    if (!buildPromotion.equals(result1)) {
        fail("While searching for single build promotion with locator \"" + locator + "\"\n" + "Expected: " + LogUtil.describeInDetail(buildPromotion) + "\n" + "Actual: " + LogUtil.describeInDetail(result1));
    }
}
Also used : SBuild(jetbrains.buildServer.serverSide.SBuild) BuildPromotion(jetbrains.buildServer.serverSide.BuildPromotion)

Example 4 with BuildPromotion

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

the class AggregatedBuildArtifactsElementBuilder method getBuildAggregatedArtifactElement.

@NotNull
public static Element getBuildAggregatedArtifactElement(@NotNull final String path, @NotNull final List<BuildPromotion> builds, @NotNull final ServiceLocator serviceLocator) {
    final AggregatedBuildArtifactsElementBuilder result = new AggregatedBuildArtifactsElementBuilder();
    int i = 0;
    for (BuildPromotion buildPromotion : builds) {
        try {
            final Element artifactElement = BuildArtifactsFinder.getArtifactElement(buildPromotion, path, serviceLocator);
            LOG.debug("Found artifact file with path '" + path + "' in " + i + "/" + builds.size() + " build: " + LogUtil.describe(buildPromotion));
            result.add(artifactElement);
        } catch (NotFoundException e) {
            LOG.debug("Ignoring not found error in artifacts aggregation request: " + e.toString());
        } catch (AuthorizationFailedException e) {
            LOG.debug("Ignoring authentication error in artifacts aggregation request: " + e.toString());
        }
        i++;
    }
    return result.get();
}
Also used : BuildPromotion(jetbrains.buildServer.serverSide.BuildPromotion) AuthorizationFailedException(jetbrains.buildServer.server.rest.errors.AuthorizationFailedException) Element(jetbrains.buildServer.util.browser.Element) NotFoundException(jetbrains.buildServer.server.rest.errors.NotFoundException) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with BuildPromotion

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

the class RootApiRequest method serveBuildFieldShort.

@GET
@ApiOperation(value = "serveBuildFieldShort", hidden = true)
@Path("/{projectLocator}/{btLocator}/{buildLocator}/{field}")
@Produces("text/plain")
public String serveBuildFieldShort(@PathParam("projectLocator") String projectLocator, @PathParam("btLocator") String buildTypeLocator, @PathParam("buildLocator") String buildLocator, @PathParam("field") String field) {
    SProject project = myProjectFinder.getItem(projectLocator);
    SBuildType buildType = myBuildTypeFinder.getBuildType(project, buildTypeLocator, false);
    final BuildPromotion buildPromotion = myBuildFinder.getBuildPromotion(buildType, buildLocator);
    return Build.getFieldValue(buildPromotion, field, new BeanContext(myDataProvider.getBeanFactory(), myDataProvider.getServer(), myApiUrlBuilder));
}
Also used : BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) BuildPromotion(jetbrains.buildServer.serverSide.BuildPromotion) SBuildType(jetbrains.buildServer.serverSide.SBuildType) SProject(jetbrains.buildServer.serverSide.SProject) 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