Search in sources :

Example 1 with FilesGroup

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;
}
Also used : FileSpec(org.jfrog.filespecs.FileSpec) FilesGroup(org.jfrog.filespecs.entities.FilesGroup)

Example 2 with FilesGroup

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

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);
}
Also used : DownloadableArtifact(org.jfrog.build.api.dependency.DownloadableArtifact) Dependency(org.jfrog.build.extractor.ci.Dependency) FilesGroup(org.jfrog.filespecs.entities.FilesGroup)

Example 4 with FilesGroup

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;
}
Also used : FilesGroup(org.jfrog.filespecs.entities.FilesGroup)

Example 5 with FilesGroup

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);
    }
}
Also used : FilesGroup(org.jfrog.filespecs.entities.FilesGroup)

Aggregations

FilesGroup (org.jfrog.filespecs.entities.FilesGroup)8 FileSpec (org.jfrog.filespecs.FileSpec)5 Test (org.testng.annotations.Test)3 Dependency (org.jfrog.build.extractor.ci.Dependency)2 CreateReleaseBundleRequest (org.jfrog.build.extractor.clientConfiguration.client.distribution.request.CreateReleaseBundleRequest)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 DownloadableArtifact (org.jfrog.build.api.dependency.DownloadableArtifact)1 DownloadResponse (org.jfrog.build.client.DownloadResponse)1 BuildInfo (org.jfrog.build.extractor.ci.BuildInfo)1 Module (org.jfrog.build.extractor.ci.Module)1 GetReleaseBundleStatusResponse (org.jfrog.build.extractor.clientConfiguration.client.distribution.response.GetReleaseBundleStatusResponse)1 DeployDetails (org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails)1 JsonUtils.toJsonString (org.jfrog.build.extractor.clientConfiguration.util.JsonUtils.toJsonString)1 Property (org.jfrog.filespecs.properties.Property)1