use of org.jfrog.build.extractor.ci.Dependency in project build-info by JFrogDev.
the class Utils method checkWebserviceDependency.
/**
* Check commons-collections:commons-collections:3.2 dependency under webservice module.
*
* @param webservice - The webservice module
*/
private static void checkWebserviceDependency(Module webservice) {
Dependency commonsCollections = webservice.getDependencies().stream().filter(dependency -> StringUtils.equals(dependency.getId(), "commons-collections:commons-collections:3.2")).findAny().orElse(null);
assertNotNull(commonsCollections);
assertEquals(commonsCollections.getType(), "jar");
assertEquals(commonsCollections.getMd5(), "7b9216b608d550787bdf43a63d88bf3b");
assertEquals(commonsCollections.getSha1(), "f951934aa5ae5a88d7e6dfaa6d32307d834a88be");
assertEquals(commonsCollections.getSha256(), "093fea360752de55afcb80cf713403eb1a66cb7dc0d529955b6f4a96f975df5c");
assertEquals(commonsCollections.getRequestedBy(), new String[][] { { "org.jfrog.test.gradle.publish:webservice:1.0-SNAPSHOT" } });
}
use of org.jfrog.build.extractor.ci.Dependency in project build-info by JFrogDev.
the class DockerImage method setDependenciesAndArtifacts.
/**
* Search the docker image in Artifactory and add all artifacts & dependencies into Module.
*/
private void setDependenciesAndArtifacts(ModuleBuilder moduleBuilder, ArtifactoryManager artifactoryManager) throws IOException {
DockerLayer historyLayer = layers.getByDigest(imageId);
if (historyLayer == null) {
throw new IllegalStateException("Could not find the history docker layer: " + imageId + " for image: " + imageTag + " in Artifactory.");
}
int dependencyLayerNum = DockerUtils.getNumberOfDependentLayers(artifactoryManager.download(historyLayer.getFullPath()).getContent());
LinkedHashSet<Dependency> dependencies = new LinkedHashSet<>();
LinkedHashSet<Artifact> artifacts = new LinkedHashSet<>();
// Filter out duplicate layers from manifest by using HashSet.
// Docker manifest may hold 'empty layers', as a result, docker promote will fail to promote the same layer more than once.
Iterator<String> it = DockerUtils.getLayersDigests(manifest).iterator();
for (int i = 0; i < dependencyLayerNum; i++) {
String digest = it.next();
DockerLayer layer = layers.getByDigest(digest);
Dependency dependency = new DependencyBuilder().id(layer.getFileName()).sha1(layer.getSha1()).build();
dependencies.add(dependency);
Artifact artifact = new ArtifactBuilder(layer.getFileName()).sha1(layer.getSha1()).remotePath(layer.getPath()).build();
artifacts.add(artifact);
}
moduleBuilder.dependencies(new ArrayList<>(dependencies));
while (it.hasNext()) {
String digest = it.next();
DockerLayer layer = layers.getByDigest(digest);
if (layer == null) {
continue;
}
Artifact artifact = new ArtifactBuilder(layer.getFileName()).sha1(layer.getSha1()).remotePath(layer.getPath()).build();
artifacts.add(artifact);
}
moduleBuilder.artifacts(new ArrayList<>(artifacts));
}
use of org.jfrog.build.extractor.ci.Dependency in project build-info by JFrogDev.
the class DockerExtractorTest method validatePulledDockerImage.
private void validatePulledDockerImage(BuildInfo buildInfo, String image) {
assertEquals(buildInfo.getModules().size(), 1);
Module module = buildInfo.getModules().get(0);
assertEquals(module.getType(), "docker");
List<Dependency> dependencies = module.getDependencies();
validateImageDependencies(dependencies, image);
}
use of org.jfrog.build.extractor.ci.Dependency in project build-info by JFrogDev.
the class NpmBuildInfoExtractor method collectDependencies.
/**
* For each scope ('development' or 'production'):
* 1. Run 'npm ls' command.
* 2. From 'npm ls' command results - Create a tree of 'NpmPackageInfo's.
* 3. Collect the dependencies from the tree.
*
* @param workingDir - Project's directory
* @return List of dependencies
* @see NpmPackageInfo
*/
private List<Dependency> collectDependencies(Path workingDir) throws Exception {
Map<String, Dependency> dependencies = new ConcurrentHashMap<>();
List<NpmScope> scopes = getNpmScopes();
if (scopes.isEmpty()) {
return new ArrayList<>();
}
for (NpmScope scope : scopes) {
List<String> extraListArgs = new ArrayList<>();
extraListArgs.add("--" + scope);
JsonNode jsonNode = npmDriver.list(workingDir.toFile(), extraListArgs);
populateDependenciesMap(dependencies, getDependenciesMapFromLatestBuild(), jsonNode, scope, workingDir);
}
return new ArrayList<>(dependencies.values());
}
Aggregations