Search in sources :

Example 1 with SBuild

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;
}
Also used : SBuild(jetbrains.buildServer.serverSide.SBuild) File(java.io.File) IOException(java.io.IOException) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with SBuild

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());
}
Also used : SBuild(jetbrains.buildServer.serverSide.SBuild) TestGroupName(jetbrains.buildServer.serverSide.TestGroupName)

Example 3 with SBuild

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));
    }
}
Also used : SBuild(jetbrains.buildServer.serverSide.SBuild) BuildPromotion(jetbrains.buildServer.serverSide.BuildPromotion)

Example 4 with SBuild

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;
}
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 5 with SBuild

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;
}
Also used : SBuild(jetbrains.buildServer.serverSide.SBuild) ServletOutputStream(javax.servlet.ServletOutputStream) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

SBuild (jetbrains.buildServer.serverSide.SBuild)6 File (java.io.File)3 ServletOutputStream (javax.servlet.ServletOutputStream)2 BuildPromotion (jetbrains.buildServer.serverSide.BuildPromotion)2 Nullable (org.jetbrains.annotations.Nullable)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Build (jetbrains.buildServer.Build)1 Locator (jetbrains.buildServer.server.rest.data.Locator)1 TestGroupName (jetbrains.buildServer.serverSide.TestGroupName)1 NotNull (org.jetbrains.annotations.NotNull)1