Search in sources :

Example 1 with ArtifactManager

use of jenkins.model.ArtifactManager in project artifact-manager-s3-plugin by jenkinsci.

the class JCloudsArtifactManager method copyAllArtifactsAndStashes.

@Override
public void copyAllArtifactsAndStashes(Run<?, ?> to, TaskListener listener) throws IOException, InterruptedException {
    ArtifactManager am = to.pickArtifactManager();
    if (!(am instanceof JCloudsArtifactManager)) {
        throw new AbortException("Cannot copy artifacts and stashes to " + to + " using " + am.getClass().getName());
    }
    JCloudsArtifactManager dest = (JCloudsArtifactManager) am;
    String prefix = getBlobPath("", PREFIX, key, id);
    BlobStore blobStore = getContext(BLOB_CONTAINER).getBlobStore();
    Iterator<StorageMetadata> it = new JCloudsBlobStore.PageSetIterable(blobStore, BLOB_CONTAINER, ListContainerOptions.Builder.prefix(prefix).recursive());
    while (it.hasNext()) {
        StorageMetadata sm = it.next();
        String path = sm.getName();
        assert path.startsWith(prefix);
        String destPath = getBlobPath(path.substring(prefix.length()), PREFIX, dest.key, dest.id);
        LOGGER.fine("copying " + path + " to " + destPath);
        blobStore.copyBlob(BLOB_CONTAINER, path, BLOB_CONTAINER, destPath, CopyOptions.NONE);
    }
// TODO print some summary to listener
}
Also used : StorageMetadata(org.jclouds.blobstore.domain.StorageMetadata) ArtifactManager(jenkins.model.ArtifactManager) BlobStore(org.jclouds.blobstore.BlobStore) AbortException(hudson.AbortException)

Aggregations

AbortException (hudson.AbortException)1 ArtifactManager (jenkins.model.ArtifactManager)1 BlobStore (org.jclouds.blobstore.BlobStore)1 StorageMetadata (org.jclouds.blobstore.domain.StorageMetadata)1