Search in sources :

Example 11 with Module

use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.

the class GoPublish method createBuild.

private BuildInfo createBuild() {
    BuildInfo buildInfo = new BuildInfo();
    String moduleId = StringUtils.defaultIfBlank(buildInfoModuleId, moduleName);
    Module module = new ModuleBuilder().type(ModuleType.GO).id(moduleId).repository(deploymentRepo).artifacts(artifactList).build();
    buildInfo.setModules(Collections.singletonList(module));
    return buildInfo;
}
Also used : BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder) Module(org.jfrog.build.extractor.ci.Module)

Example 12 with Module

use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.

the class GoRun method createBuild.

private BuildInfo createBuild() {
    BuildInfo buildInfo = new BuildInfo();
    String moduleId = StringUtils.defaultIfBlank(buildInfoModuleId, moduleName);
    Module module = new ModuleBuilder().type(ModuleType.GO).id(moduleId).dependencies(dependenciesList).build();
    buildInfo.setModules(Collections.singletonList(module));
    return buildInfo;
}
Also used : BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder) Module(org.jfrog.build.extractor.ci.Module)

Example 13 with Module

use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.

the class GoExtractorTest method goRunPublishTest.

/*
     * 1. Build project1 locally (with default Go proxy)
     * 2. Publish project1 package to Artifactory. (Project1 is a dependency for project2)
     * 3. Build project2 with Artifactory for resolution.
     */
@Test
public void goRunPublishTest() {
    Path projectDir = null;
    ArrayListMultimap<String, String> properties = ArrayListMultimap.create();
    try {
        // Run Go build on project1 locally
        Project project = Project.PROJECT_1;
        projectDir = createProjectDir(project.targetDir, project.projectOrigin);
        GoRun goRun = new GoRun(GO_BUILD_CMD, projectDir, null, null, StringUtils.EMPTY, getUsername(), getAdminToken(), getLog(), env);
        BuildInfo project1BuildInfo = goRun.execute();
        // Check successful execution
        assertNotNull(project1BuildInfo);
        // Publish project1 to Artifactory
        GoPublish goPublish = new GoPublish(artifactoryManagerBuilder, properties, localRepo1, projectDir, project.getVersion(), null, getLog());
        BuildInfo publishBuildInfo = goPublish.execute();
        // Check successful execution
        assertNotNull(publishBuildInfo);
        project1BuildInfo.append(publishBuildInfo);
        // Check correctness of the module, dependencies and artifacts
        assertEquals(project1BuildInfo.getModules().size(), 1);
        Module module = project1BuildInfo.getModules().get(0);
        assertEquals(module.getType(), "go");
        assertEquals(module.getId(), project.getModuleId());
        assertEquals(module.getRepository(), localRepo1);
        Set<String> moduleDependencies = module.getDependencies().stream().map(Dependency::getId).collect(Collectors.toSet());
        assertEquals(moduleDependencies, project.dependencies);
        Set<String> moduleArtifacts = module.getArtifacts().stream().map(Artifact::getName).collect(Collectors.toSet());
        assertEquals(moduleArtifacts, project.getArtifactSet());
        String expectedRemotePath = project.getRemotePath();
        module.getArtifacts().stream().map(BaseBuildFileBean::getRemotePath).forEach(remotePath -> assertEquals(remotePath, expectedRemotePath));
        // Run Go build on project2 using Artifactory for resolution
        project = Project.PROJECT_2;
        projectDir = createProjectDir(project.targetDir, project.projectOrigin);
        goRun = new GoRun(GO_BUILD_CMD, projectDir, null, artifactoryManagerBuilder, virtualRepo, getUsername(), getAdminToken(), getLog(), env);
        BuildInfo project2BuildInfo = goRun.execute();
        // Check successful execution and correctness of the module, dependencies and artifacts
        assertNotNull(project2BuildInfo);
        assertEquals(project2BuildInfo.getModules().size(), 1);
        module = project2BuildInfo.getModules().get(0);
        assertEquals(module.getId(), project.getModuleId());
        moduleDependencies = module.getDependencies().stream().map(Dependency::getId).collect(Collectors.toSet());
        assertEquals(moduleDependencies, project.dependencies);
    } catch (Exception e) {
        fail(ExceptionUtils.getStackTrace(e));
    } finally {
        if (projectDir != null) {
            FileUtils.deleteQuietly(projectDir.toFile());
        }
    }
}
Also used : Path(java.nio.file.Path) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Dependency(org.jfrog.build.extractor.ci.Dependency) Module(org.jfrog.build.extractor.ci.Module) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 14 with Module

use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.

the class DockerExtractorTest method pushAndValidateImage.

private void pushAndValidateImage(DockerPush dockerPush, String repo, String imageTag, String shortImageTag) {
    BuildInfo buildInfo = dockerPush.execute();
    Module module = getAndValidateModule(buildInfo, SHORT_IMAGE_NAME + ":" + shortImageTag, repo);
    List<Artifact> artifacts = module.getArtifacts();
    validateImageArtifacts(artifacts, imageTag);
    assertEquals(7, artifacts.size());
    module.getArtifacts().forEach(artifact -> assertEquals(artifact.getRemotePath(), SHORT_IMAGE_NAME + "/" + shortImageTag));
    assertEquals(5, module.getDependencies().size());
}
Also used : BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Module(org.jfrog.build.extractor.ci.Module) Artifact(org.jfrog.build.extractor.ci.Artifact)

Example 15 with Module

use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.

the class Utils method checkBuildInfoModules.

/**
 * Check expected build info modules.
 *
 * @param buildInfo                  - The build info
 * @param expectedModules            - Number of expected modules.
 * @param expectedArtifactsPerModule - Number of expected artifacts in each module.
 */
private static void checkBuildInfoModules(BuildInfo buildInfo, int expectedModules, int expectedArtifactsPerModule) {
    List<Module> modules = buildInfo.getModules();
    assertEquals(modules.size(), expectedModules);
    for (Module module : modules) {
        if (expectedArtifactsPerModule > 0) {
            assertEquals(module.getArtifacts().size(), expectedArtifactsPerModule);
        } else {
            assertNull(module.getArtifacts());
        }
        switch(module.getId()) {
            case "org.jfrog.test.gradle.publish:webservice:1.0-SNAPSHOT":
                assertEquals(module.getDependencies().size(), 7);
                if (expectedArtifactsPerModule > 0) {
                    checkWebserviceArtifact(module);
                }
                checkWebserviceDependency(module);
                break;
            case "org.jfrog.test.gradle.publish:api:1.0-SNAPSHOT":
                assertEquals(module.getDependencies().size(), 5);
                break;
            case "org.jfrog.test.gradle.publish:shared:1.0-SNAPSHOT":
                assertEquals(module.getDependencies().size(), 0);
                break;
            default:
                fail("Unexpected module ID: " + module.getId());
        }
    }
}
Also used : Module(org.jfrog.build.extractor.ci.Module)

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