use of org.jfrog.build.extractor.builder.ModuleBuilder 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.builder.ModuleBuilder 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.builder.ModuleBuilder in project build-info by JFrogDev.
the class DockerImage method generateBuildInfoModule.
public Module generateBuildInfoModule(Log logger, DockerUtils.CommandType cmdType) throws IOException, InterruptedException {
try (ArtifactoryManager artifactoryManager = artifactoryManagerBuilder.build()) {
ModuleBuilder moduleBuilder = new ModuleBuilder().type(ModuleType.DOCKER).id(substringAfterLast(imageTag, "/")).repository(targetRepo);
try {
findAndSetManifestFromArtifactory(artifactoryManager, logger, cmdType);
} catch (IOException e) {
// The manifest could not be found in Artifactory.
// Yet, we do not fail the build, but return an empty build-info instead.
// The reason for not failing build is that there's a chance that the image was replaced
// with another image, deployed to the same repo path.
// This can happen if two parallel jobs build the same image. In that case, the build-info
// for this build will be empty.
logger.error("The manifest could not be fetched from Artifactory.");
return moduleBuilder.build();
}
logger.info("Fetching details of published docker layers from Artifactory...");
if (cmdType == DockerUtils.CommandType.Push) {
setDependenciesAndArtifacts(moduleBuilder, artifactoryManager);
} else {
setDependencies(moduleBuilder);
}
setBuildInfoModuleProps(moduleBuilder);
return moduleBuilder.build();
}
}
use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.
the class BuildExtractorUtilsTest method testBuildToJson.
public void testBuildToJson() throws IOException {
String[] requestedByA = new String[] { "parentA", "b", "moduleId" };
String[] requestedByB = new String[] { "parentB", "d", "moduleId" };
Dependency dependencyA = new DependencyBuilder().id("depA").addRequestedBy(requestedByA).addRequestedBy(requestedByB).build();
Module module = new ModuleBuilder().id("moduleId").addDependency(dependencyA).build();
BuildInfo buildInfo = new BuildInfoBuilder("buildId").number("12").started("34").addModule(module).build();
// Serialize and deserialize again
BuildInfo actualBuildInfo = jsonStringToBuildInfo(buildInfoToJsonString(buildInfo));
// Check buildInfo
assertEquals(actualBuildInfo.getName(), buildInfo.getName());
assertEquals(actualBuildInfo.getNumber(), buildInfo.getNumber());
assertEquals(actualBuildInfo.getStarted(), buildInfo.getStarted());
// Check module
Module actualModule = actualBuildInfo.getModule(module.getId());
assertNotNull(actualModule);
// Check dependency
assertEquals(actualModule.getDependencies().size(), 1);
Dependency actualDependency = actualModule.getDependencies().get(0);
assertEquals(actualDependency.getId(), dependencyA.getId());
// Check requestedBy
String[][] requestedBy = actualDependency.getRequestedBy();
assertEquals(ArrayUtils.getLength(requestedBy), 2);
assertEquals(requestedBy[0], requestedByA);
assertEquals(requestedBy[1], requestedByB);
}
use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.
the class BuildInfoMavenBuilderTest method testDuplicateModuleArtifacts.
/**
* Validates adding same artifacts to different modules
*/
public void testDuplicateModuleArtifacts() {
ModuleBuilder module1 = new ModuleBuilder().type(ModuleType.MAVEN).id("id");
module1.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).build());
module1.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).build());
ModuleBuilder module2 = new ModuleBuilder().type(ModuleType.MAVEN).id("id");
module2.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).build());
module2.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).build());
BuildInfoMavenBuilder builder = new BuildInfoMavenBuilder("test").number("4").started("test");
builder.addModule(module1.build());
builder.addModule(module2.build());
BuildInfo buildInfo = builder.build();
List<Module> modules = buildInfo.getModules();
assertFalse(modules.isEmpty(), "A buildInfo module should have been added.");
assertEquals(modules.size(), 1, "Expected to find only 1 module.");
assertEquals(modules.get(0).getId(), "id", "Expected to find module with id = 'id'.");
assertEquals(modules.get(0).getType(), "maven", "Expected to find module with type = 'maven'.");
List<Artifact> artifacts = modules.get(0).getArtifacts();
assertEquals(artifacts.size(), 2, "Expected to find only 2 artifacts.");
assertEquals(artifacts.get(0).getName(), "artifact1", "Unexpected artifact name.");
assertEquals(artifacts.get(0).getMd5(), MD5, "Unexpected MD5 checksum.");
assertEquals(artifacts.get(0).getSha1(), SHA1, "Unexpected SHA-1 checksum.");
assertEquals(artifacts.get(0).getSha256(), SHA2, "Unexpected SHA-256 checksum.");
assertEquals(artifacts.get(1).getName(), "artifact2", "Unexpected artifact name.");
assertEquals(artifacts.get(1).getMd5(), MD5, "Unexpected MD5 checksum.");
assertEquals(artifacts.get(1).getSha1(), SHA1, "Unexpected SHA-1 checksum.");
assertEquals(artifacts.get(1).getSha256(), SHA2, "Unexpected SHA-256 checksum.");
}
Aggregations