Search in sources :

Example 16 with DeployDetails

use of org.jfrog.build.client.DeployDetails in project build-info by JFrogDev.

the class SpecsHelper method uploadArtifactsBySpec.

/**
 * Uploads and returns List of artifacts according to a provided by the user upload fileSpec
 *
 * @param uploadSpec The required spec represented as String
 * @param workspace File object that represents the workspace
 * @param buildProperties Upload properties
 * @param client ArtifactoryBuildInfoClient which will do the actual upload
 * @return Set of DeployDetails that was calculated from the given params
 * @throws IOException Thrown if any error occurs while reading the file, calculating the
 *                     checksums or in case of any file system exception
 * @throws NoSuchAlgorithmException Thrown if any of the given algorithms aren't supported
 */
public List<Artifact> uploadArtifactsBySpec(String uploadSpec, File workspace, Multimap<String, String> buildProperties, ArtifactoryBuildInfoClient client) throws IOException, NoSuchAlgorithmException {
    Spec spec = this.getDownloadUploadSpec(uploadSpec, new UploadSpecValidator());
    Set<DeployDetails> artifactsToDeploy = getDeployDetails(spec, workspace, buildProperties);
    deploy(client, artifactsToDeploy);
    return convertDeployDetailsToArtifacts(artifactsToDeploy);
}
Also used : DeployDetails(org.jfrog.build.client.DeployDetails) UploadSpecValidator(org.jfrog.build.extractor.clientConfiguration.util.spec.validator.UploadSpecValidator)

Example 17 with DeployDetails

use of org.jfrog.build.client.DeployDetails in project build-info by JFrogDev.

the class DownloadTest method testDownloadFilesProvider.

/**
 * Create and upload files to Artifactory.
 * The test files are created according to the data provided in testFilesMap
 */
@DataProvider
private Object[][] testDownloadFilesProvider() throws IOException, NoSuchAlgorithmException {
    Map<String, Integer> testFilesMap = new HashMap<String, Integer>() {

        {
            put("file1", MIN_SIZE_FOR_CONCURRENT_DOWNLOAD);
            put("file2", MIN_SIZE_FOR_CONCURRENT_DOWNLOAD - 1);
        }
    };
    Object[][] tests = new Object[testFilesMap.size()][4];
    try {
        int i = 0;
        for (Map.Entry<String, Integer> entry : testFilesMap.entrySet()) {
            String fileName = entry.getKey();
            int fileSize = entry.getValue();
            // Create file and calculate checksum
            File file = createRandomFile(tempWorkspace.getPath() + File.pathSeparatorChar + fileName, fileSize);
            Map<String, String> checksum = FileChecksumCalculator.calculateChecksums(file, SHA1_ALGORITHM_NAME, MD5_ALGORITHM_NAME);
            DeployDetails deployDetails = new DeployDetails.Builder().file(file).artifactPath(TEST_REPO_PATH + "/" + fileName).targetRepository(localRepo).md5(checksum.get(MD5_ALGORITHM_NAME)).sha1(checksum.get(SHA1_ALGORITHM_NAME)).explode(false).build();
            // Upload artifact
            buildInfoClient.deployArtifact(deployDetails);
            long createdFileSize = deployDetails.getFile().length();
            tests[i] = new Object[] { checksum, fileName, createdFileSize };
            i++;
        }
    } finally {
        FileUtils.deleteDirectory(tempWorkspace);
    }
    return tests;
}
Also used : DeployDetails(org.jfrog.build.client.DeployDetails) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) DataProvider(org.testng.annotations.DataProvider)

Example 18 with DeployDetails

use of org.jfrog.build.client.DeployDetails in project build-info by JFrogDev.

the class GradleBuildInfoExtractor method calculateArtifacts.

private List<Artifact> calculateArtifacts(Iterable<GradleDeployDetails> deployDetails) throws Exception {
    List<Artifact> artifacts = newArrayList(transform(deployDetails, new Function<GradleDeployDetails, Artifact>() {

        public Artifact apply(GradleDeployDetails from) {
            PublishArtifactInfo publishArtifact = from.getPublishArtifact();
            DeployDetails deployDetails = from.getDeployDetails();
            String artifactPath = deployDetails.getArtifactPath();
            int index = artifactPath.lastIndexOf('/');
            return new ArtifactBuilder(artifactPath.substring(index + 1)).type(getTypeString(publishArtifact.getType(), publishArtifact.getClassifier(), publishArtifact.getExtension())).md5(deployDetails.getMd5()).sha1(deployDetails.getSha1()).build();
        }
    }));
    return artifacts;
}
Also used : Function(com.google.common.base.Function) DeployDetails(org.jfrog.build.client.DeployDetails) BuildInfoExtractorUtils.getModuleIdString(org.jfrog.build.extractor.BuildInfoExtractorUtils.getModuleIdString) BuildInfoExtractorUtils.getTypeString(org.jfrog.build.extractor.BuildInfoExtractorUtils.getTypeString) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact)

Example 19 with DeployDetails

use of org.jfrog.build.client.DeployDetails in project build-info by JFrogDev.

the class DeployTask method deployArtifacts.

private void deployArtifacts(Set<GradleDeployDetails> allDeployDetails, ArtifactoryBuildInfoClient client, IncludeExcludePatterns patterns) 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;
        }
        client.deployArtifact(deployDetails);
    }
}
Also used : DeployDetails(org.jfrog.build.client.DeployDetails) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails)

Aggregations

DeployDetails (org.jfrog.build.client.DeployDetails)19 File (java.io.File)9 ArtifactoryClientConfiguration (org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration)5 GradleDeployDetails (org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails)5 IOException (java.io.IOException)4 BuildInfoExtractorUtils.getModuleIdString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getModuleIdString)4 BuildInfoExtractorUtils.getTypeString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getTypeString)4 Artifact (org.jfrog.build.api.Artifact)3 Map (java.util.Map)2 Module (org.jfrog.build.api.Module)2 ArtifactBuilder (org.jfrog.build.api.builder.ArtifactBuilder)2 IncludeExcludePatterns (org.jfrog.build.extractor.clientConfiguration.IncludeExcludePatterns)2 PublishArtifactInfo (org.jfrog.gradle.plugin.artifactory.extractor.PublishArtifactInfo)2 Function (com.google.common.base.Function)1 RandomAccessFile (java.io.RandomAccessFile)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 QName (javax.xml.namespace.QName)1 EndArtifactPublishEvent (org.apache.ivy.core.event.publish.EndArtifactPublishEvent)1