Search in sources :

Example 11 with BuildInfo

use of org.jfrog.build.extractor.ci.BuildInfo 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 BuildInfo

use of org.jfrog.build.extractor.ci.BuildInfo 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 BuildInfo

use of org.jfrog.build.extractor.ci.BuildInfo 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 BuildInfo

use of org.jfrog.build.extractor.ci.BuildInfo 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 BuildInfo

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

the class IssuesCollector method getPreviousVcsRevision.

/**
 * Gets the previous vcs revision from the LATEST build published to Artifactory.
 */
private String getPreviousVcsRevision(ArtifactoryManagerBuilder artifactoryManagerBuilder, String prevBuildName, Vcs prevVcs, String project) throws IOException {
    try (ArtifactoryManager artifactoryManager = artifactoryManagerBuilder.build()) {
        // Get LATEST build info from Artifactory
        BuildInfo previousBuildInfo = artifactoryManager.getBuildInfo(prevBuildName, LATEST, project);
        if (previousBuildInfo == null) {
            return "";
        }
        // Gets the first revision related to the current git repository.
        List<Vcs> vcsList = previousBuildInfo.getVcs();
        if (vcsList != null && vcsList.size() > 0) {
            for (Vcs curVcs : previousBuildInfo.getVcs()) {
                if (StringUtils.isNotEmpty(curVcs.getRevision()) && StringUtils.equals(curVcs.getUrl(), prevVcs.getUrl())) {
                    return curVcs.getRevision();
                }
            }
        }
        return "";
    }
}
Also used : ArtifactoryManager(org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Vcs(org.jfrog.build.extractor.ci.Vcs)

Aggregations

BuildInfo (org.jfrog.build.extractor.ci.BuildInfo)28 Module (org.jfrog.build.extractor.ci.Module)18 IOException (java.io.IOException)11 Path (java.nio.file.Path)6 ModuleBuilder (org.jfrog.build.extractor.builder.ModuleBuilder)6 Test (org.testng.annotations.Test)6 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 BuildInfoBuilder (org.jfrog.build.extractor.builder.BuildInfoBuilder)3 Artifact (org.jfrog.build.extractor.ci.Artifact)3 Vcs (org.jfrog.build.extractor.ci.Vcs)3 ArtifactoryClientConfiguration (org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration)3 DockerImage (org.jfrog.build.extractor.docker.types.DockerImage)3 Map (java.util.Map)2 BuildInfoExtractorUtils.jsonStringToBuildInfo (org.jfrog.build.extractor.BuildInfoExtractorUtils.jsonStringToBuildInfo)2 Agent (org.jfrog.build.extractor.ci.Agent)2 BuildAgent (org.jfrog.build.extractor.ci.BuildAgent)2 Dependency (org.jfrog.build.extractor.ci.Dependency)2 Issue (org.jfrog.build.extractor.ci.Issue)2