use of jetbrains.buildServer.serverSide.SBuild in project teamcity-torrent-plugin by JetBrains.
the class AbstractLinksController method doHandle.
@Nullable
@Override
protected ModelAndView doHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws Exception {
String buildIdParam = request.getParameter("buildId");
if (buildIdParam == null) {
return null;
}
try {
long buildId = Long.parseLong(buildIdParam);
SBuild build = myServer.findBuildInstanceById(buildId);
if (build != null && myConfigurator.isDownloadEnabled()) {
Collection<File> torrentFiles = myTorrentsManager.getTorrentFiles(build);
File baseDir = myTorrentsManager.getTorrentFilesBaseDir(build.getArtifactsDirectory());
Map<File, String> torrentsAndArtifacts = getArtifactsWithTorrents(baseDir, torrentFiles);
writeResponse(response, torrentsAndArtifacts, build);
response.setStatus(HttpServletResponse.SC_OK);
}
} catch (Exception e) {
// ignore
}
return null;
}
use of jetbrains.buildServer.serverSide.SBuild in project teamcity-rest by JetBrains.
the class SortTestRunsByNewComparator method compare.
@Override
public int compare(STestRun o1, STestRun o2) {
// see also STestRun.NEW_FIRST_NAME_COMPARATOR
// New failure goes first
boolean isNew1 = o1.isNewFailure();
boolean isNew2 = o2.isNewFailure();
if (isNew1 && !isNew2) {
return -1;
}
if (!isNew1 && isNew2) {
return 1;
}
final TestGroupName grp1 = o1.getTest().getName().getGroupName();
final TestGroupName grp2 = o2.getTest().getName().getGroupName();
final int grpCompare = grp1.compareTo(grp2);
if (grpCompare != 0)
return grpCompare;
final String name1 = o1.getTest().getName().getAsString();
final String name2 = o2.getTest().getName().getAsString();
final int nameCompare = name1.compareTo(name2);
if (nameCompare != 0)
return nameCompare;
// Failure goes first
boolean isFailed1 = o1.getStatus().isFailed();
boolean isFailed2 = o2.getStatus().isFailed();
if (isFailed1 && !isFailed2) {
return -1;
}
if (!isFailed1 && isFailed2) {
return 1;
}
// That's what STestRun.NEW_FIRST_NAME_COMPARATOR does not compare
// We need that to be consistent with equals.
SBuild build1 = o1.getBuild();
SBuild build2 = o2.getBuild();
int datesComparison = build1.getServerStartDate().compareTo(build2.getServerStartDate());
if (datesComparison != 0)
return datesComparison;
if (build1.getBuildId() != build2.getBuildId()) {
return Long.compare(build1.getBuildId(), build2.getBuildId());
}
return Integer.compare(o1.getOrderId(), o2.getOrderId());
}
use of jetbrains.buildServer.serverSide.SBuild 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.SBuild 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;
}
use of jetbrains.buildServer.serverSide.SBuild in project teamcity-torrent-plugin by JetBrains.
the class TorrentLinksController method doHandle.
@Nullable
@Override
protected ModelAndView doHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws Exception {
String buildIdParam = request.getParameter("buildId");
if (buildIdParam == null) {
return null;
}
try {
long buildId = Long.parseLong(buildIdParam);
SBuild build = myServer.findBuildInstanceById(buildId);
if (build != null && myConfigurator.isDownloadEnabled()) {
Collection<File> torrentFiles = myTorrentsManager.getTorrentFiles(build);
File baseDir = myTorrentsManager.getTorrentFilesBaseDir(build.getArtifactsDirectory());
List<String> paths = getArtifactsWithTorrents(baseDir, torrentFiles);
response.setContentType("text/plain");
ServletOutputStream output = response.getOutputStream();
try {
for (String name : paths) {
output.println(name);
}
} finally {
output.close();
}
}
} catch (Exception e) {
// ignore
}
return null;
}
Aggregations