use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.
the class GoExtractorTest method deployTestDependencies.
private void deployTestDependencies(Project... projects) throws IOException {
for (Project project : projects) {
for (String ext : GO_PACKAGE_EXTENSIONS) {
File pkgFile = project.projectOrigin.toPath().resolve("v" + project.version + ext).toFile();
if (!pkgFile.exists())
continue;
DeployDetails deployDetails = new DeployDetails.Builder().file(pkgFile).targetRepository(localRepo1).artifactPath(project.getTargetPath(ext)).packageType(DeployDetails.PackageType.GO).build();
artifactoryManager.upload(deployDetails);
}
}
}
use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.
the class DeployTask method deployArtifacts.
private void deployArtifacts(Set<GradleDeployDetails> allDeployDetails, ArtifactoryManager artifactoryManager, IncludeExcludePatterns patterns, String logPrefix, int minChecksumDeploySizeKb) throws IOException {
for (GradleDeployDetails detail : allDeployDetails) {
DeployDetails deployDetails = detail.getDeployDetails();
String artifactPath = deployDetails.getArtifactPath();
if (PatternMatcher.pathConflicts(artifactPath, patterns)) {
log.log(LogLevel.LIFECYCLE, "Skipping the deployment of '" + artifactPath + "' due to the defined include-exclude patterns.");
continue;
}
try {
ArtifactoryUploadResponse response = artifactoryManager.upload(deployDetails, logPrefix, minChecksumDeploySizeKb);
detail.getDeployDetails().setDeploySucceeded(true);
detail.getDeployDetails().setSha256(response.getChecksums().getSha256());
} catch (IOException e) {
detail.getDeployDetails().setDeploySucceeded(false);
detail.getDeployDetails().setSha256("");
throw e;
}
}
}
use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.
the class TaskHelperConfigurations method gradleDeployDetails.
private GradleDeployDetails gradleDeployDetails(PublishArtifact artifact, String configuration, @Nullable String artifactPath, @Nullable Set<String> processedFiles) {
ArtifactoryClientConfiguration.PublisherHandler publisher = ArtifactoryPluginUtil.getPublisherHandler(getProject());
if (publisher == null) {
return null;
}
File file = artifact.getFile();
if (processedFiles != null && processedFiles.contains(file.getAbsolutePath())) {
return null;
}
if (!file.exists()) {
throw new GradleException("File '" + file.getAbsolutePath() + "'" + " does not exists, and need to be published!");
}
if (processedFiles != null) {
processedFiles.add(file.getAbsolutePath());
}
String revision = getProject().getVersion().toString();
Map<String, String> extraTokens = new HashMap<>();
if (StringUtils.isNotBlank(artifact.getClassifier())) {
extraTokens.put("classifier", artifact.getClassifier());
}
String pattern = publisher.getIvyArtifactPattern();
String gid = getProject().getGroup().toString();
if (publisher.isM2Compatible()) {
gid = gid.replace(".", "/");
}
DeployDetails.Builder deployDetailsBuilder = new DeployDetails.Builder().file(file).packageType(DeployDetails.PackageType.GRADLE);
try {
Map<String, String> checksums = FileChecksumCalculator.calculateChecksums(file, MD5_ALGORITHM, SHA1_ALGORITHM, SHA256_ALGORITHM);
deployDetailsBuilder.md5(checksums.get(MD5_ALGORITHM)).sha1(checksums.get(SHA1_ALGORITHM)).sha256(SHA256_ALGORITHM);
} catch (Exception e) {
throw new GradleException("Failed to calculate checksums for artifact: " + file.getAbsolutePath(), e);
}
if (artifactPath == null) {
artifactPath = IvyPatternHelper.substitute(pattern, gid, getModuleName(), revision, artifact.getName(), artifact.getType(), artifact.getExtension(), configuration, extraTokens, null);
}
deployDetailsBuilder.artifactPath(artifactPath);
deployDetailsBuilder.targetRepository(getTargetRepository(artifactPath, publisher));
PublishArtifactInfo artifactInfo = new PublishArtifactInfo(artifact);
Map<String, String> propsToAdd = getPropsToAdd(artifactInfo, configuration);
deployDetailsBuilder.addProperties(propsToAdd);
DeployDetails details = deployDetailsBuilder.build();
return new GradleDeployDetails(artifactInfo, details, getProject());
}
use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.
the class GoPublish method deploy.
/**
* Deploy pkg file and add it as an buildInfo's artifact
*/
private Artifact deploy(ArtifactoryManager artifactoryManager, File deployedFile, String extension) throws Exception {
String artifactName = version + "." + extension;
Map<String, String> checksums = FileChecksumCalculator.calculateChecksums(deployedFile, MD5_ALGORITHM, SHA1_ALGORITHM, SHA256_ALGORITHM);
String remotePath = moduleName + "/@v";
DeployDetails deployDetails = new DeployDetails.Builder().file(deployedFile).targetRepository(deploymentRepo).addProperties(properties).artifactPath(remotePath + "/" + artifactName).md5(checksums.get(MD5_ALGORITHM)).sha1(checksums.get(SHA1_ALGORITHM)).sha256(checksums.get(SHA256_ALGORITHM)).packageType(DeployDetails.PackageType.GO).build();
ArtifactoryUploadResponse response = artifactoryManager.upload(deployDetails);
return new ArtifactBuilder(moduleName + ":" + artifactName).md5(response.getChecksums().getMd5()).sha1(response.getChecksums().getSha1()).sha256(response.getChecksums().getSha256()).remotePath(remotePath).build();
}
use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.
the class BuildDeploymentHelper method prepareDeployableArtifacts.
private Map<String, Set<DeployDetails>> prepareDeployableArtifacts(BuildInfo buildInfo, Map<String, DeployDetails> deployableArtifactBuilders) {
Map<String, Set<DeployDetails>> deployableArtifactsByModule = new LinkedHashMap<>();
List<Module> modules = buildInfo.getModules();
for (Module module : modules) {
Set<DeployDetails> moduleDeployableArtifacts = new LinkedHashSet<>();
List<Artifact> artifacts = module.getArtifacts();
if (artifacts != null) {
for (Artifact artifact : artifacts) {
String artifactId = BuildInfoExtractorUtils.getArtifactId(module.getId(), artifact.getName());
DeployDetails deployable = deployableArtifactBuilders.get(artifactId);
if (deployable != null) {
File file = deployable.getFile();
setArtifactChecksums(file, artifact);
artifact.setRemotePath(deployable.getArtifactPath());
moduleDeployableArtifacts.add(new DeployDetails.Builder().artifactPath(deployable.getArtifactPath()).file(file).md5(artifact.getMd5()).sha1(artifact.getSha1()).sha256(artifact.getSha256()).addProperties(deployable.getProperties()).targetRepository(deployable.getTargetRepository()).packageType(DeployDetails.PackageType.MAVEN).build());
}
}
}
if (!moduleDeployableArtifacts.isEmpty()) {
deployableArtifactsByModule.put(module.getId(), moduleDeployableArtifacts);
}
}
return deployableArtifactsByModule;
}
Aggregations