use of org.jfrog.filespecs.entities.FilesGroup 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.entities.FilesGroup 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.entities.FilesGroup in project build-info by JFrogDev.
the class DependenciesDownloaderHelper method downloadDependencies.
/**
* Download dependencies by the provided spec using the provided in the constructor client.
* returns a distinct list of downloaded artifacts
*
* @param downloadSpec the download spec
* @return list of downloaded artifacts
* @throws IOException in case of IO error
*/
public List<Dependency> downloadDependencies(FileSpec downloadSpec) throws IOException {
ArtifactorySearcher searcher = new ArtifactorySearcher(downloader.getArtifactoryManager(), log);
Set<DownloadableArtifact> downloadableArtifacts;
List<AqlSearchResult.SearchEntry> searchResults;
HashSet<Dependency> resolvedDependencies = new HashSet<>();
for (FilesGroup file : downloadSpec.getFiles()) {
log.debug("Downloading dependencies using spec: \n" + file.toString());
this.downloader.setFlatDownload(BooleanUtils.toBoolean(file.getFlat()));
searchResults = searcher.SearchByFileSpec(file);
downloadableArtifacts = fetchDownloadableArtifactsFromResult(searchResults, Boolean.valueOf(file.getExplode()), file.getTarget());
if (file.getSpecType() == FilesGroup.SpecType.PATTERN) {
replaceTargetPlaceholders(file.getPattern(), downloadableArtifacts, file.getTarget());
}
resolvedDependencies.addAll(downloadDependencies(downloadableArtifacts));
}
return new ArrayList<>(resolvedDependencies);
}
use of org.jfrog.filespecs.entities.FilesGroup in project build-info by JFrogDev.
the class EditPropertiesHelper method editProperties.
public boolean editProperties(FileSpec spec, EditPropertiesActionType editType, String props) throws IOException {
ArtifactorySearcher searcher = new ArtifactorySearcher(artifactoryManager, log);
// Here to mark that at least one action has been successfully made. Needed for the failNoOp flag.
boolean propertiesSet = false;
for (FilesGroup file : spec.getFiles()) {
log.debug("Editing properties using spec: \n" + file.toString());
if (editType == EditPropertiesActionType.SET) {
propertiesSet = setPropertiesOnResults(searcher.SearchByFileSpec(file), props) || propertiesSet;
} else {
propertiesSet = deletePropertiesOnResults(searcher.SearchByFileSpec(file), props) || propertiesSet;
}
}
return propertiesSet;
}
use of org.jfrog.filespecs.entities.FilesGroup in project build-info by JFrogDev.
the class SpecDeploymentProducer method producerRun.
@Override
public void producerRun() throws InterruptedException {
log.debug(String.format("[Thread %s] starting run()", Thread.currentThread().getName()));
try {
// Iterate over FileSpecs
for (FilesGroup uploadFile : spec.getFiles()) {
if (Thread.interrupted()) {
break;
}
log.debug(String.format("[Thread %s] getting deploy details from the following json: \n %s ", Thread.currentThread().getName(), uploadFile.toString()));
// Execute FileSpec
SingleSpecDeploymentProducer fileSpecProducer = new SingleSpecDeploymentProducer(uploadFile, workspace, buildProperties);
fileSpecProducer.executeSpec(deployDetailsSet, executor);
}
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
// Throw unchecked exception for the UncaughtExceptionHandler
throw new RuntimeException(e);
}
}
Aggregations