Search in sources :

Example 1 with ArtifactoryUploadResponse

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;
}
Also used : Path(java.nio.file.Path) DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) ArtifactoryUploadResponse(org.jfrog.build.client.ArtifactoryUploadResponse)

Example 2 with ArtifactoryUploadResponse

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();
}
Also used : DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder) ArtifactBuilder(org.jfrog.build.extractor.builder.ArtifactBuilder) ArtifactoryManagerBuilder(org.jfrog.build.extractor.clientConfiguration.ArtifactoryManagerBuilder) ArtifactoryUploadResponse(org.jfrog.build.client.ArtifactoryUploadResponse) ArtifactBuilder(org.jfrog.build.extractor.builder.ArtifactBuilder)

Example 3 with ArtifactoryUploadResponse

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);
        }
    });
}
Also used : ArtifactoryUploadResponse(org.jfrog.build.client.ArtifactoryUploadResponse) IOException(java.io.IOException)

Example 4 with ArtifactoryUploadResponse

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;
        }
    }
}
Also used : DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) ArtifactoryUploadResponse(org.jfrog.build.client.ArtifactoryUploadResponse) IOException(java.io.IOException)

Example 5 with ArtifactoryUploadResponse

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();
}
Also used : DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) ArtifactoryUploadResponse(org.jfrog.build.client.ArtifactoryUploadResponse) ArtifactBuilder(org.jfrog.build.extractor.builder.ArtifactBuilder)

Aggregations

ArtifactoryUploadResponse (org.jfrog.build.client.ArtifactoryUploadResponse)6 DeployDetails (org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails)4 IOException (java.io.IOException)2 ArtifactBuilder (org.jfrog.build.extractor.builder.ArtifactBuilder)2 Path (java.nio.file.Path)1 ModuleBuilder (org.jfrog.build.extractor.builder.ModuleBuilder)1 ArtifactoryManagerBuilder (org.jfrog.build.extractor.clientConfiguration.ArtifactoryManagerBuilder)1