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