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;
}
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;
}
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());
}
}
}
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);
}
}
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());
}
}
}
Aggregations