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;
}
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));
}
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));
}
}
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();
}
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));
}
Aggregations