Search in sources :

Example 21 with Module

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;
}
Also used : Module(org.jfrog.build.extractor.ci.Module)

Example 22 with 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());
    }
}
Also used : Path(java.nio.file.Path) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Module(org.jfrog.build.extractor.ci.Module) File(java.io.File) Test(org.testng.annotations.Test)

Example 23 with Module

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);
}
Also used : Dependency(org.jfrog.build.extractor.ci.Dependency) Module(org.jfrog.build.extractor.ci.Module)

Example 24 with Module

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());
    }
}
Also used : Path(java.nio.file.Path) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Module(org.jfrog.build.extractor.ci.Module) Test(org.testng.annotations.Test)

Example 25 with Module

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;
}
Also used : DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) Artifact(org.jfrog.build.extractor.ci.Artifact) Module(org.jfrog.build.extractor.ci.Module) File(java.io.File)

Aggregations

Module (org.jfrog.build.extractor.ci.Module)28 BuildInfo (org.jfrog.build.extractor.ci.BuildInfo)18 IOException (java.io.IOException)9 ModuleBuilder (org.jfrog.build.extractor.builder.ModuleBuilder)7 Path (java.nio.file.Path)6 Dependency (org.jfrog.build.extractor.ci.Dependency)6 Test (org.testng.annotations.Test)6 File (java.io.File)5 Artifact (org.jfrog.build.extractor.ci.Artifact)5 ArrayList (java.util.ArrayList)4 BuildInfoExtractorUtils.getModuleIdString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getModuleIdString)3 BuildInfoExtractorUtils.getTypeString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getTypeString)3 DockerImage (org.jfrog.build.extractor.docker.types.DockerImage)3 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)2 Project (org.apache.tools.ant.Project)2 DeployDetails (org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails)2 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Arrays (java.util.Arrays)1 Date (java.util.Date)1