Search in sources :

Example 1 with FileSpec

use of org.jfrog.filespecs.FileSpec in project build-info by JFrogDev.

the class DistributionManagerTest method createSpec.

FileSpec createSpec() throws IOException {
    String fileName = uploadFile();
    FilesGroup filesGroup = new FilesGroup().setTargetProps("key1=value1,value2").setPattern(localRepo1 + "/data/" + fileName);
    FileSpec fileSpec = new FileSpec();
    fileSpec.addFilesGroup(filesGroup);
    return fileSpec;
}
Also used : FileSpec(org.jfrog.filespecs.FileSpec) FilesGroup(org.jfrog.filespecs.entities.FilesGroup)

Example 2 with FileSpec

use of org.jfrog.filespecs.FileSpec in project build-info by JFrogDev.

the class RemoteDistributionManagerTest method distributeWithMappingTest.

@Test
public void distributeWithMappingTest() throws IOException {
    // Create a release bundle with path mapping
    String fileName = uploadFile();
    FileSpec fileSpec = new FileSpec();
    FilesGroup filesGroup = new FilesGroup().setPattern(localRepo1 + "/data/(*)").setTarget(localRepo2 + "/data2/{1}");
    fileSpec.addFilesGroup(filesGroup);
    CreateReleaseBundleRequest request = new CreateReleaseBundleRequest.Builder(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION).spec(fileSpec).signImmediately(true).build();
    distributionManager.createReleaseBundle(request);
    // Distribute the release bundle
    distributionManager.distributeReleaseBundle(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION, true, createDistributionRequest());
    // Download the file from the new path
    DownloadResponse downloadResponse = artifactoryManager.download(localRepo2 + "/data2/" + fileName);
    assertTrue(StringUtils.isNotBlank(downloadResponse.getContent()));
    // Delete release bundle
    distributionManager.deleteReleaseBundle(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION, true, createDeletionRequest());
}
Also used : FileSpec(org.jfrog.filespecs.FileSpec) DownloadResponse(org.jfrog.build.client.DownloadResponse) JsonUtils.toJsonString(org.jfrog.build.extractor.clientConfiguration.util.JsonUtils.toJsonString) FilesGroup(org.jfrog.filespecs.entities.FilesGroup) CreateReleaseBundleRequest(org.jfrog.build.extractor.clientConfiguration.client.distribution.request.CreateReleaseBundleRequest) Test(org.testng.annotations.Test)

Example 3 with FileSpec

use of org.jfrog.filespecs.FileSpec in project build-info by JFrogDev.

the class SpecsHelper method uploadArtifactsBySpec.

/**
 * Upload artifacts according to a given spec, return a list describing the deployed items.
 *
 * @param uploadSpec                The required spec represented as String
 * @param numberOfThreads           Number of concurrent threads to use for handling uploads
 * @param workspace                 File object that represents the workspace
 * @param buildProperties           Upload properties
 * @param artifactoryManagerBuilder ArtifactoryManagerBuilder which will build the ArtifactoryManager per the number of passed threads number to perform 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
 */
public List<Artifact> uploadArtifactsBySpec(String uploadSpec, int numberOfThreads, File workspace, Multimap<String, String> buildProperties, ArtifactoryManagerBuilder artifactoryManagerBuilder) throws Exception {
    FileSpec fileSpec = FileSpec.fromString(uploadSpec);
    FileSpecsValidation.validateUploadFileSpec(fileSpec, this.log);
    try (ArtifactoryManager artifactoryManager = artifactoryManagerBuilder.build()) {
        // Create producer Runnable
        ProducerRunnableBase[] producerRunnable = new ProducerRunnableBase[] { new SpecDeploymentProducer(fileSpec, workspace, buildProperties) };
        // Create consumer Runnables
        ConsumerRunnableBase[] consumerRunnables = new ConsumerRunnableBase[numberOfThreads];
        for (int i = 0; i < numberOfThreads; i++) {
            consumerRunnables[i] = new SpecDeploymentConsumer(artifactoryManager);
        }
        // Create the deployment executor
        ProducerConsumerExecutor deploymentExecutor = new ProducerConsumerExecutor(log, producerRunnable, consumerRunnables, CONNECTION_POOL_SIZE);
        deploymentExecutor.start();
        Set<DeployDetails> deployedArtifacts = ((SpecDeploymentProducer) producerRunnable[0]).getDeployedArtifacts();
        return convertDeployDetailsToArtifacts(deployedArtifacts);
    }
}
Also used : ProducerConsumerExecutor(org.jfrog.build.extractor.producerConsumer.ProducerConsumerExecutor) DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) FileSpec(org.jfrog.filespecs.FileSpec) ArtifactoryManager(org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager) ProducerRunnableBase(org.jfrog.build.extractor.producerConsumer.ProducerRunnableBase) ConsumerRunnableBase(org.jfrog.build.extractor.producerConsumer.ConsumerRunnableBase)

Example 4 with FileSpec

use of org.jfrog.filespecs.FileSpec in project build-info by JFrogDev.

the class SpecsHelper method editPropertiesBySpec.

@SuppressWarnings("unused")
public boolean editPropertiesBySpec(String spec, ArtifactoryManager artifactoryManager, EditPropertiesHelper.EditPropertiesActionType editType, String props) throws IOException {
    EditPropertiesHelper helper = new EditPropertiesHelper(artifactoryManager, log);
    FileSpec fileSpec = FileSpec.fromString(spec);
    FileSpecsValidation.validateSearchBasedFileSpec(fileSpec);
    return helper.editProperties(fileSpec, editType, props);
}
Also used : FileSpec(org.jfrog.filespecs.FileSpec) EditPropertiesHelper(org.jfrog.build.extractor.clientConfiguration.util.EditPropertiesHelper)

Example 5 with FileSpec

use of org.jfrog.filespecs.FileSpec in project build-info by JFrogDev.

the class SpecsHelper method downloadArtifactsBySpec.

/**
 * Downloads Artifacts by spec and returns a list of the downloaded dependencies.
 * The artifacts will be downloaded using the provided client.
 * In case of relative path the artifacts will be downloaded to the targetDirectory.
 *
 * @param spec            the spec to use for download.
 * @param client          the client to use for download.
 * @param targetDirectory the target directory in case of relative path in the spec
 * @return A list of the downloaded dependencies.
 * @throws IOException in case of IOException
 */
public List<Dependency> downloadArtifactsBySpec(String spec, ArtifactoryManager client, String targetDirectory) throws IOException {
    // During download, temp directories are created. This will make sure 'java.io.tmpdir' property is defined in Unix.
    handleJavaTmpdirProperty();
    DependenciesDownloaderHelper helper = new DependenciesDownloaderHelper(client, targetDirectory, log);
    FileSpec fileSpec = FileSpec.fromString(spec);
    FileSpecsValidation.validateSearchBasedFileSpec(fileSpec);
    return helper.downloadDependencies(fileSpec);
}
Also used : DependenciesDownloaderHelper(org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper) FileSpec(org.jfrog.filespecs.FileSpec)

Aggregations

FileSpec (org.jfrog.filespecs.FileSpec)10 FilesGroup (org.jfrog.filespecs.entities.FilesGroup)5 CreateReleaseBundleRequest (org.jfrog.build.extractor.clientConfiguration.client.distribution.request.CreateReleaseBundleRequest)3 Test (org.testng.annotations.Test)3 ReleaseNotes (org.jfrog.build.extractor.clientConfiguration.client.distribution.types.ReleaseNotes)2 DeployDetails (org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails)2 File (java.io.File)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 Path (java.nio.file.Path)1 StringJoiner (java.util.StringJoiner)1 DownloadResponse (org.jfrog.build.client.DownloadResponse)1 BuildInfo (org.jfrog.build.extractor.ci.BuildInfo)1 Dependency (org.jfrog.build.extractor.ci.Dependency)1 Module (org.jfrog.build.extractor.ci.Module)1 ArtifactoryManager (org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager)1 UpdateReleaseBundleRequest (org.jfrog.build.extractor.clientConfiguration.client.distribution.request.UpdateReleaseBundleRequest)1 GetReleaseBundleStatusResponse (org.jfrog.build.extractor.clientConfiguration.client.distribution.response.GetReleaseBundleStatusResponse)1 DependenciesDownloaderHelper (org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper)1 EditPropertiesHelper (org.jfrog.build.extractor.clientConfiguration.util.EditPropertiesHelper)1