Skip to content

Commit

Permalink
Merge pull request #105 from thiagofigueiro/nexus-support
Browse files Browse the repository at this point in the history
Nexus 3 version upgrade
  • Loading branch information
thiagofigueiro authored Feb 22, 2020
2 parents d74a9cf + 6cfcc9e commit 3f336aa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
dist: bionic
sudo: required
env:
- NEXUS_VERSION=3.17.0
- NEXUS_VERSION=3.18.1
- NEXUS_VERSION=3.19.1
- NEXUS_VERSION=3.20.0
- NEXUS_VERSION=3.20.1
# FIXME: sonatype introduced a breaking change in the groovy api. Again.
# - NEXUS_VERSION=3.21.1
services:
- docker
before_install:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import find_packages, setup

package_name = 'nexus3-cli'
package_version = '3.0.0'
package_version = '3.0.1'

requires = [
'click>=7.0.0,<8',
Expand Down
22 changes: 13 additions & 9 deletions src/nexuscli/api/script/groovy/nexus3-cli-cleanup-policy.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import groovy.json.JsonSlurper
import groovy.json.JsonBuilder
import java.util.concurrent.TimeUnit

import org.sonatype.nexus.cleanup.storage.CleanupPolicy
import org.sonatype.nexus.cleanup.storage.CleanupPolicyStorage
import static org.sonatype.nexus.repository.search.DefaultComponentMetadataProducer.IS_PRERELEASE_KEY
import static org.sonatype.nexus.repository.search.DefaultComponentMetadataProducer.LAST_BLOB_UPDATED_KEY
Expand All @@ -17,7 +16,7 @@ def cleanupPolicyStorage = container.lookup(CleanupPolicyStorage.class.getName()
try {
parsed_args = new JsonSlurper().parseText(args)
} catch(Exception ex) {
// "list" operation
log.debug("list")
def policies = []
cleanupPolicyStorage.getAll().each {
policies << toJsonString(it)
Expand All @@ -35,6 +34,7 @@ if (parsed_args.name == null) {

// "get" operation
if (parsed_args.size() == 1) {
log.debug("get")
existingPolicy = cleanupPolicyStorage.get(parsed_args.name)
return toJsonString(existingPolicy)
}
Expand All @@ -54,14 +54,18 @@ if (cleanupPolicyStorage.exists(parsed_args.name)) {

// "create" operation
format = parsed_args.format == "all" ? "ALL_FORMATS" : parsed_args.format

log.debug("Creating Cleanup Policy <name=${parsed_args.name}>")
cleanupPolicy = new CleanupPolicy(
name: parsed_args.name,
notes: parsed_args.notes,
format: format,
mode: 'deletion',
criteria: criteriaMap
)
cleanupPolicy = cleanupPolicyStorage.newCleanupPolicy()

log.debug("Configuring Cleanup Policy <policy=${cleanupPolicy}>")
cleanupPolicy.setName(parsed_args.name)
cleanupPolicy.setNotes(parsed_args.notes)
cleanupPolicy.setFormat(format)
cleanupPolicy.setMode('deletion')
cleanupPolicy.setCriteria(criteriaMap)

log.debug("Adding Cleanup Policy <policy=${cleanupPolicy}>")
cleanupPolicyStorage.add(cleanupPolicy)
return toJsonString(cleanupPolicy)

Expand Down

0 comments on commit 3f336aa

Please sign in to comment.