Skip to content

Instantly share code, notes, and snippets.

Daniel Wamara dwamara

  • DWI Technologies
  • Berlin, Germany
Block or report user

Report or block dwamara

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dwamara
dwamara / nexus3-clean-timestamped-snapshots.groovy
Last active Jul 13, 2019
Due to the requirement from Maven to not have unique versions of SNAPSHOTS, even when a policy to clean the SNAPSHOTS is specified in Nexus 3, SNAPSHOTS that are not cleaned still contain several versions of the SNAPSHOTS artefacts timestamped. This script allows to delete the timestamped SNAPSHOTS and to keep a certain specified amount of them
View nexus3-clean-timestamped-snapshots.groovy
import groovy.json.JsonSlurper
import groovy.transform.Field
import static groovy.time.TimeCategory.minus
import static javax.xml.bind.DatatypeConverter.printBase64Binary
@Field def params = [:]
@Field def nexus = [:]
@Field def artifactsToVersion = [:]
@Field def was_at_least_one_element_delete = false
View purge_nexus_v3_releases.groovy
import org.sonatype.nexus.repository.storage.StorageFacet;
import org.sonatype.nexus.repository.storage.Query;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
def fmt = DateTimeFormat.forPattern('yyyy-MM-dd HH:mm:ss');
// Get a repository
def repo = repository.repositoryManager.get('nuget-releases');
// Get a database transaction
def tx = repo.facet(StorageFacet).txSupplier().get();
You can’t perform that action at this time.