use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class DockerExtractorTest method getAndValidateModule.
private Module getAndValidateModule(BuildInfo buildInfo, String id, String repo) {
Module module = buildInfo.getModules().stream().filter(moduleCandidate -> StringUtils.equals(moduleCandidate.getId(), id)).findFirst().orElse(null);
assertNotNull(module);
assertEquals(module.getType(), "docker");
assertEquals(module.getRepository(), repo);
return module;
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class DockerExtractorTest method buildDockerCreateKanikoTest.
@Test
public void buildDockerCreateKanikoTest() throws IOException, InterruptedException {
Path workingDirectory = Files.createTempDirectory("build-docker-create-kaniko-test", PosixFilePermissions.asFileAttribute(Sets.newHashSet(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE)));
try {
FileUtils.copyDirectory(new File(PROJECT_PATH), workingDirectory.toFile());
Path kanikoConfig = createKanikoConfig(workingDirectory, virtualDomainName);
String kanikoFile = execKaniko(workingDirectory, virtualDomainName, kanikoConfig);
BuildDockerCreator buildDockerCreator = new BuildDockerCreator(artifactoryManagerBuilder, kanikoFile, BuildDockerCreator.ImageFileType.KANIKO, artifactProperties, dockerVirtualRepo, getLog());
BuildInfo buildInfo = buildDockerCreator.execute();
assertEquals(buildInfo.getModules().size(), 1);
Module module = getAndValidateModule(buildInfo, "hello-world:latest", dockerVirtualRepo);
module.getArtifacts().stream().map(BaseBuildFileBean::getRemotePath).forEach(remotePath -> assertEquals(remotePath, EXPECTED_REMOTE_PATH_KANIKO));
} finally {
FileUtils.deleteDirectory(workingDirectory.toFile());
}
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class DockerExtractorTest method validatePulledDockerImage.
private void validatePulledDockerImage(BuildInfo buildInfo, String image) {
assertEquals(buildInfo.getModules().size(), 1);
Module module = buildInfo.getModules().get(0);
assertEquals(module.getType(), "docker");
List<Dependency> dependencies = module.getDependencies();
validateImageDependencies(dependencies, image);
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class DockerExtractorTest method buildDockerCreateJibTest.
@Test
public void buildDockerCreateJibTest() throws IOException, InterruptedException {
Path wd = Files.createTempDirectory("build-docker-create-jib-test", PosixFilePermissions.asFileAttribute(Sets.newHashSet(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE)));
try {
FileUtils.copyDirectory(PROJECTS_ROOT.resolve("maven-jib-example").toFile(), wd.toFile());
execJib(wd);
// Run build-docker-create
BuildDockerCreator.ImageFileType imageFileType = BuildDockerCreator.ImageFileType.JIB;
BuildInfo buildInfo = new BuildDockerCreator(artifactoryManagerBuilder, getJibImageJsonPath(wd), imageFileType, artifactProperties, dockerVirtualRepo, getLog()).execute();
// Check modules
assertEquals(buildInfo.getModules().size(), 3);
Module module = getAndValidateModule(buildInfo, "multi1", dockerVirtualRepo);
assertFalse(module.getArtifacts().isEmpty());
module = getAndValidateModule(buildInfo, "multi2", dockerVirtualRepo);
assertFalse(module.getArtifacts().isEmpty());
module = getAndValidateModule(buildInfo, "multi3", dockerVirtualRepo);
assertFalse(module.getArtifacts().isEmpty());
} finally {
FileUtils.deleteDirectory(wd.toFile());
}
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class BuildDeploymentHelper method prepareDeployableArtifacts.
private Map<String, Set<DeployDetails>> prepareDeployableArtifacts(BuildInfo buildInfo, Map<String, DeployDetails> deployableArtifactBuilders) {
Map<String, Set<DeployDetails>> deployableArtifactsByModule = new LinkedHashMap<>();
List<Module> modules = buildInfo.getModules();
for (Module module : modules) {
Set<DeployDetails> moduleDeployableArtifacts = new LinkedHashSet<>();
List<Artifact> artifacts = module.getArtifacts();
if (artifacts != null) {
for (Artifact artifact : artifacts) {
String artifactId = BuildInfoExtractorUtils.getArtifactId(module.getId(), artifact.getName());
DeployDetails deployable = deployableArtifactBuilders.get(artifactId);
if (deployable != null) {
File file = deployable.getFile();
setArtifactChecksums(file, artifact);
artifact.setRemotePath(deployable.getArtifactPath());
moduleDeployableArtifacts.add(new DeployDetails.Builder().artifactPath(deployable.getArtifactPath()).file(file).md5(artifact.getMd5()).sha1(artifact.getSha1()).sha256(artifact.getSha256()).addProperties(deployable.getProperties()).targetRepository(deployable.getTargetRepository()).packageType(DeployDetails.PackageType.MAVEN).build());
}
}
}
if (!moduleDeployableArtifacts.isEmpty()) {
deployableArtifactsByModule.put(module.getId(), moduleDeployableArtifacts);
}
}
return deployableArtifactsByModule;
}
Aggregations