use of org.jfrog.build.client.ArtifactoryUploadResponse in project build-info by JFrogDev.
the class DistributionManagerTest method uploadFile.
String uploadFile() throws IOException {
String fileName = RandomStringUtils.randomAlphabetic(10);
Path tmpFile = tempWorkspace.toPath().resolve(fileName).toAbsolutePath();
Files.createFile(tmpFile);
Files.write(tmpFile, RandomStringUtils.randomAlphabetic(10).getBytes(StandardCharsets.UTF_8));
DeployDetails deployDetails = new DeployDetails.Builder().file(tmpFile.toFile()).artifactPath("data/" + fileName).targetRepository(localRepo1).build();
ArtifactoryUploadResponse response = artifactoryManager.upload(deployDetails);
assertFalse(CollectionUtils.hasElements(response.getErrors()));
return fileName;
}
use of org.jfrog.build.client.ArtifactoryUploadResponse in project build-info by JFrogDev.
the class NpmPublish method doDeploy.
private void doDeploy() throws IOException {
DeployDetails deployDetails = new DeployDetails.Builder().file(path.toFile()).targetRepository(repo).addProperties(properties).artifactPath(npmPackageInfo.getDeployPath()).packageType(DeployDetails.PackageType.NPM).build();
ArtifactoryUploadResponse response = artifactoryManager.upload(deployDetails);
deployedArtifact = new ArtifactBuilder(npmPackageInfo.getModuleId()).md5(response.getChecksums().getMd5()).sha1(response.getChecksums().getSha1()).remotePath(StringUtils.substringBeforeLast(npmPackageInfo.getDeployPath(), "/")).build();
}
use of org.jfrog.build.client.ArtifactoryUploadResponse in project build-info by JFrogDev.
the class ModuleParallelDeployHelper method deploy.
private void deploy(ArtifactoryManager artifactoryManager, Set<DeployDetails> deployableArtifacts, String logPrefix) {
deployableArtifacts.forEach(artifact -> {
try {
ArtifactoryUploadResponse response = artifactoryManager.upload(artifact, logPrefix);
// Save information returned from Artifactory after the deployment.
artifact.setDeploySucceeded(true);
artifact.setSha256(response.getChecksums().getSha256());
// When a maven SNAPSHOT artifact is deployed, Artifactory adds a timestamp to the artifact name, after the artifact is deployed.
// ArtifactPath needs to be updated accordingly.
artifact.setArtifactPath(response.getPath());
} catch (IOException e) {
artifact.setDeploySucceeded(false);
artifact.setSha256("");
throw new RuntimeException("Error occurred while publishing artifact to Artifactory: " + artifact.getFile() + ".\n Skipping deployment of remaining artifacts (if any) and build info.", e);
}
});
}
use of org.jfrog.build.client.ArtifactoryUploadResponse 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.client.ArtifactoryUploadResponse 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();
}
Aggregations