Created
May 12, 2017 12:56
-
-
Save witokondoria/f2aa99f0f53d73bb116684b98b32bf03 to your computer and use it in GitHub Desktop.
wiping nexus3 docker images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.sonatype.nexus.repository.storage.StorageFacet | |
def dockerRepository = repository.repositoryManager.get('docker-staging') | |
def dockerBlobStore = blobStore.blobStoreManager.get(dockerRepository.configuration.attributes.storage.blobStoreName) | |
def storageTx = dockerRepository.facet(StorageFacet.class).txSupplier().get() | |
try { | |
storageTx.begin() | |
dockerRepository.stop() | |
def bucket = storageTx.findBucket(dockerRepository) | |
def images = storageTx.browseComponents(bucket).asCollection().asImmutable() | |
log.info("Nexus Components - Docker Images: ${images.size()}") | |
images.forEach { component -> | |
storageTx.deleteComponent(component) | |
} | |
storageTx.browseAssets(bucket).forEach { asset -> | |
storageTx.deleteAsset(asset) | |
} | |
storageTx.commit() | |
dockerBlobStore.compact() | |
} finally { | |
dockerRepository.start() | |
storageTx.close() | |
log.info("Dangling cleanup done") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment