Skip to content
Closed
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
23 changes: 23 additions & 0 deletions core/src/main/java/org/testcontainers/utility/MountableFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
@Slf4j
public class MountableFile implements Transferable {

private static final String BITBUCKET_CLONE_DIR_ENV = "BITBUCKET_CLONE_DIR";
// private static final String BITBUCKET_TMP_SUBDIR = "tmp";
private static final String TESTCONTAINERS_TMP_DIR_PREFIX = ".testcontainers-tmp-";
private static final String OS_MAC_TMP_DIR = "/tmp";
private static final int BASE_FILE_MODE = 0100000;
Expand Down Expand Up @@ -241,8 +243,29 @@ private String extractClassPathResourceToTempLocation(final String hostPath) {
return tmpLocation.getAbsolutePath();
}

private boolean isOnBitbucket() {
final String bbCloneDir = System.getenv(BITBUCKET_CLONE_DIR_ENV);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call getBitbucketCloneDir() here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably some other vars will be required so i'd prefer not to join BB checking and getting some BB variable

return bbCloneDir != null && bbCloneDir.length() > 0;
}

private String getBitbucketCloneDir() {
return System.getenv(BITBUCKET_CLONE_DIR_ENV);
}

private File createTempDirectory() {
try {
if (isOnBitbucket()) {
//Path tmpPath = Paths.get(getBitbucketCloneDir(), BITBUCKET_TMP_SUBDIR);
//if (!java.nio.file.Files.exists(tmpPath)) {
// Files.createDirectory(tmpPath);
//}
Path bbClonePath = Paths.get(getBitbucketCloneDir());
if (!java.nio.file.Files.exists(bbClonePath)) {
Files.createDirectory(bbClonePath);
}
return Files.createTempDirectory(bbClonePath, TESTCONTAINERS_TMP_DIR_PREFIX).toFile();
}

if (SystemUtils.IS_OS_MAC) {
return Files.createTempDirectory(Paths.get(OS_MAC_TMP_DIR), TESTCONTAINERS_TMP_DIR_PREFIX).toFile();
}
Expand Down