Search in sources :

Example 16 with BuildInfo

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

the class NugetRun method execute.

@Override
public BuildInfo execute() {
    BuildInfo buildInfo = null;
    try {
        prepareAndRunCmd();
        if (!StringUtils.isBlank(module)) {
            ModuleBuilder builder = new ModuleBuilder().type(ModuleType.NUGET).id(module);
            modulesList.add(builder.build());
        }
        collectDependencies();
        buildInfo = new BuildInfo();
        buildInfo.setModules(modulesList);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
    return buildInfo;
}
Also used : BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 17 with BuildInfo

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

the class NpmPublish method createBuild.

private BuildInfo createBuild() {
    String moduleID = StringUtils.isNotBlank(module) ? module : npmPackageInfo.toString();
    List<Artifact> artifactList = Collections.singletonList(deployedArtifact);
    Module module = new ModuleBuilder().type(ModuleType.NPM).id(moduleID).repository(repo).artifacts(artifactList).build();
    List<Module> modules = Collections.singletonList(module);
    BuildInfo buildInfo = new BuildInfo();
    buildInfo.setModules(modules);
    return buildInfo;
}
Also used : ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Module(org.jfrog.build.extractor.ci.Module) Artifact(org.jfrog.build.extractor.ci.Artifact)

Example 18 with BuildInfo

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

the class NpmExtractorTest method npmPublishTest.

@SuppressWarnings("unused")
@Test(dataProvider = "npmPublishProvider")
public void npmPublishTest(Project project, ArrayListMultimap<String, String> props, String targetPath, String packageName) {
    Path projectDir = null;
    try {
        // Run npm publish
        projectDir = createProjectDir(project);
        Path path = StringUtils.isNotBlank(packageName) ? projectDir.resolve(packageName) : projectDir;
        NpmPublish npmPublish = new NpmPublish(artifactoryManagerBuilder, props, path, localRepo1, log, null, null);
        BuildInfo buildInfo = npmPublish.execute();
        assertEquals(buildInfo.getModules().size(), 1);
        Module module = buildInfo.getModules().get(0);
        // Check correctness of the module and the artifact
        assertEquals(module.getType(), "npm");
        assertEquals(module.getId(), project.getModuleId());
        assertEquals(module.getRepository(), localRepo1);
        assertEquals(module.getArtifacts().size(), 1);
        assertEquals(module.getArtifacts().get(0).getName(), project.getModuleId());
        assertEquals(module.getArtifacts().get(0).getRemotePath(), project.getRemotePath());
        // DownloadBase the artifact and check for its properties
        StringJoiner propertiesBuilder = new StringJoiner(";");
        props.entries().forEach(property -> propertiesBuilder.add(property.getKey() + "=" + property.getValue()));
        FilesGroup fileSpec = new FilesGroup();
        fileSpec.setProps(propertiesBuilder.toString());
        fileSpec.setPattern(localRepo1 + "/" + targetPath);
        fileSpec.setTarget(projectDir.toString());
        FileSpec spec = new FileSpec();
        spec.addFilesGroup(fileSpec);
        assertEquals(downloaderHelper.downloadDependencies(spec).size(), 1);
    } catch (Exception e) {
        fail(ExceptionUtils.getStackTrace(e));
    } finally {
        if (projectDir != null) {
            FileUtils.deleteQuietly(projectDir.toFile());
        }
    }
}
Also used : Path(java.nio.file.Path) FileSpec(org.jfrog.filespecs.FileSpec) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Module(org.jfrog.build.extractor.ci.Module) StringJoiner(java.util.StringJoiner) FilesGroup(org.jfrog.filespecs.entities.FilesGroup) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 19 with BuildInfo

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

the class NugetExtractorTest method executeAndAssertBuildInfo.

private void executeAndAssertBuildInfo(NugetRun nugetRun, String[] expectedModules, int... expectedDependencies) {
    BuildInfo buildInfo = nugetRun.execute();
    assertNotNull(buildInfo);
    assertEquals(buildInfo.getModules().size(), expectedModules.length);
    for (int i = 0; i < expectedModules.length; i++) {
        Module module = buildInfo.getModules().get(i);
        // Check correctness of the module and dependencies
        assertEquals(module.getType(), "nuget");
        assertEquals(module.getId(), expectedModules[i]);
        assertTrue(module.getDependencies().size() > 0);
    }
}
Also used : BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Module(org.jfrog.build.extractor.ci.Module)

Example 20 with BuildInfo

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

the class GoExtractorTest method goRunTest.

@Test(dataProvider = "goRunProvider")
public void goRunTest(Project project, String args, ArtifactoryManagerBuilder artifactoryManagerBuilder, String repo) {
    Path projectDir = null;
    try {
        // Run Go build
        projectDir = createProjectDir(project.targetDir, project.projectOrigin);
        GoRun goRun = new GoRun(args, projectDir, null, artifactoryManagerBuilder, repo, getUsername(), getAdminToken(), getLog(), env);
        BuildInfo buildInfo = goRun.execute();
        // Check successful execution and correctness of the module and dependencies
        assertNotNull(buildInfo);
        assertEquals(buildInfo.getModules().size(), 1);
        Module module = buildInfo.getModules().get(0);
        assertEquals(module.getType(), "go");
        assertEquals(module.getId(), project.getModuleId());
        Set<String> 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) Module(org.jfrog.build.extractor.ci.Module) IOException(java.io.IOException) Test(org.testng.annotations.Test)

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