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
}
Aggregations