Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import org.jetbrains.teamcity.rest.TeamCityInstance;
import org.jetbrains.teamcity.rest.TeamCityInstanceFactory;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;

public class TeamCityFactory {

Expand Down Expand Up @@ -101,10 +101,9 @@ private GenericContainer<?> createAndStartServer() {
"-Droot.log.level=TRACE -Dteamcity.development.mode=true "
+ "-Doctopus.enable.step.vnext=true")
.withStartupTimeout(Duration.ofMinutes(2))
.withFileSystemBind(
teamCityDataDir.toAbsolutePath().toString(),
"/data/teamcity_server/datadir",
BindMode.READ_WRITE);
.withCopyFileToContainer(
MountableFile.forHostPath(teamCityDataDir.toAbsolutePath().toString()),
"/data/teamcity_server/datadir");

teamCityServer.start();
return teamCityServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.time.Instant;
import java.util.List;

import com.google.common.collect.Lists;
import com.google.common.io.Resources;
import octopus.teamcity.e2e.dsl.TeamCityContainers;
import octopus.teamcity.e2e.dsl.TeamCityFactory;
Expand Down Expand Up @@ -113,10 +112,6 @@ public void buildInformationStepPublishesToOctopusDeploy(@TempDir Path testDirec
LOG.info("Failed to execute build");
LOG.info(teamCityContainers.getAgentContainer().getLogs());
throw e;
} finally {
// Turns out, some files get written to this directory by TC (as the tcuser) - and they need
// to be destroyed.
cleanupContainers(teamCityContainers);
}
}

Expand All @@ -136,26 +131,4 @@ private void waitForBuildToFinish(final Build build, final TeamCityInstance tcRe
LOG.warn("Build {} failed to complete within expected time limit", build.getId());
throw new RuntimeException("Build Failed to complete within 30 seconds");
}

private void cleanupContainers(final TeamCityContainers teamCityContainers) {
final List<String> filesToDelete =
Lists.newArrayList(
"/data/teamcity_server/datadir/system/buildserver.tmp",
"/data/teamcity_server/datadir/system/artifacts",
"/data/teamcity_server/datadir/system/caches/plugins.unpacked",
"/data/teamcity_server/datadir/system/caches/pluginsDslCache/src",
"/data/teamcity_server/datadir/system/caches/buildsMetadata/metadataDB.tmp",
"/data/teamcity_server/datadir/system/caches/sources",
"/data/teamcity_server/datadir/system/caches/kotlinDslData",
"/data/teamcity_server/datadir/system/pluginData/avatars");

for (final String file : filesToDelete) {
try {
LOG.debug("Removing " + file);
teamCityContainers.getServerContainer().execInContainer("rm", "-rf", file);
} catch (final Exception e) {
LOG.error("Failed to delete " + file);
}
}
}
}