Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uploadArchives {
- repositories {
- mavenDeployer {
- repository(url: "http://localhost:8081/repository/my-snapshot/") {
- authentication(userName: "admin", password: "admin123")
- }
- pom.version = "${version}-SNAPSHOT"
- pom.artifactId = "my-server"
- pom.groupId = "com.example"
- }
- }
- }
- import groovy.json.JsonOutput
- import org.sonatype.nexus.repository.storage.Component
- import org.sonatype.nexus.repository.storage.Query
- import org.sonatype.nexus.repository.storage.StorageFacet
- def repoName = "eddie-test"
- def startDate = "2016/01/01"
- def artifactName = "you-artifact-name"
- def artifactVersion = "1.0.6"
- log.info(" Attempting to delete for repository: ${repoName} as of startDate: ${startDate}")
- def repo = repository.repositoryManager.get(repoName)
- StorageFacet storageFacet = repo.facet(StorageFacet)
- def tx = storageFacet.txSupplier().get()
- tx.begin()
- // build a query to return a list of components scoped by name and version
- Iterable<Component> foundComponents = tx.findComponents(Query.builder().where('name = ').param(artifactName).and('version = ').param(artifactVersion).build(), [repo])
- // extra logic for validation goes here
- if (foundComponents.size() == 1) {
- tx.deleteComponent(foundComponents[0])
- }
- tx.commit()
- log.info("done")
Add Comment
Please, Sign In to add comment