Guest User

Untitled

a guest
Nov 21st, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. uploadArchives {
  2. repositories {
  3. mavenDeployer {
  4. repository(url: "http://localhost:8081/repository/my-snapshot/") {
  5. authentication(userName: "admin", password: "admin123")
  6. }
  7. pom.version = "${version}-SNAPSHOT"
  8. pom.artifactId = "my-server"
  9. pom.groupId = "com.example"
  10. }
  11. }
  12. }
  13.  
  14. import groovy.json.JsonOutput
  15. import org.sonatype.nexus.repository.storage.Component
  16. import org.sonatype.nexus.repository.storage.Query
  17. import org.sonatype.nexus.repository.storage.StorageFacet
  18.  
  19. def repoName = "eddie-test"
  20. def startDate = "2016/01/01"
  21. def artifactName = "you-artifact-name"
  22. def artifactVersion = "1.0.6"
  23.  
  24. log.info(" Attempting to delete for repository: ${repoName} as of startDate: ${startDate}")
  25.  
  26. def repo = repository.repositoryManager.get(repoName)
  27. StorageFacet storageFacet = repo.facet(StorageFacet)
  28. def tx = storageFacet.txSupplier().get()
  29.  
  30. tx.begin()
  31.  
  32. // build a query to return a list of components scoped by name and version
  33. Iterable<Component> foundComponents = tx.findComponents(Query.builder().where('name = ').param(artifactName).and('version = ').param(artifactVersion).build(), [repo])
  34.  
  35. // extra logic for validation goes here
  36. if (foundComponents.size() == 1) {
  37. tx.deleteComponent(foundComponents[0])
  38. }
  39.  
  40. tx.commit()
  41. log.info("done")
Add Comment
Please, Sign In to add comment