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;
}
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());
}
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);
}
}
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);
}
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);
}
Aggregations