--To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/1697c6d6-ded3-4dfd-89ba-ad5adccc2e44%40glists.sonatype.com.
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.
How are you triggering the script?
On 29 Aug 2017 16:59, "Chris Cunningham" <cmcu...@gmail.com> wrote:
Hey Bradley,
Thanks for checking this out for me. I ran your script and received the same error as before regarding nested database transactions. Is there a setting in nexus or a capability we need to add to enable that behavior?
Thanks,
Chris
--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
How are you triggering the script?
On 29 Aug 2017 16:59, "Chris Cunningham" <cmcu...@gmail.com> wrote:
Hey Bradley,
Thanks for checking this out for me. I ran your script and received the same error as before regarding nested database transactions. Is there a setting in nexus or a capability we need to add to enable that behavior?
Thanks,
Chris
--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/1697c6d6-ded3-4dfd-89ba-ad5adccc2e44%40glists.sonatype.com.
--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/CAB4-bMMqyRxc6m7uWSX8roFHqmXChJS6snL8jOO73B-SqhG%2BFQ%40mail.gmail.com.
The example I provided was run via a scripting task.It should also be noted that a component may have many assets, so you may want to construct a set of components that are to be deleted and then delete those in a separate loop.Also, the current script will trigger the deletion of a component if a pom has not been downloaded in 90 days but the jar may have been downloaded more recently. Something to think about.
On Tue, Aug 29, 2017 at 11:14 AM Stuart McCulloch <mcc...@sonatype.com> wrote:
How are you triggering the script?
On 29 Aug 2017 16:59, "Chris Cunningham" <cmcu...@gmail.com> wrote:
Hey Bradley,
Thanks for checking this out for me. I ran your script and received the same error as before regarding nested database transactions. Is there a setting in nexus or a capability we need to add to enable that behavior?
Thanks,
Chris
--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/1697c6d6-ded3-4dfd-89ba-ad5adccc2e44%40glists.sonatype.com.
--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/CAB4-bMMqyRxc6m7uWSX8roFHqmXChJS6snL8jOO73B-SqhG%2BFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/a/glists.sonatype.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/CAEz28gjzL6vcF7ZUQau%2BB6gj_cC%3DtvjN2DnK0591055vnB0pQw%40mail.gmail.com.
Sorry for the delay on this, took a while before we had a good time to bounce the nexus server. We also took the opportunity to update to the latest version of nexus. Unfortunately this did not resolve the problems we were having. Upon restart we attempted to run the script written as Bradley has it on this thread, and received a null pointer exception which I have attached. I think this is due to the loop not checking if asset.ComponentID() is null. After this run however all of our scripts began returning the NestedDBTX! exception we experienced before. Is there a way to kill a deadlocked transaction in nexus?
--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/d82ce8a9-35b4-4731-a360-63e0600d9129%40glists.sonatype.com.
import org.sonatype.nexus.repository.storage.StorageFacet
import org.sonatype.nexus.repository.storage.Query
def cutoffDate = new Date().minus(90)
def repo = repository.repositoryManager.get('common-components')
StorageFacet storageFacet = repo.facet(StorageFacet)
def tx = storageFacet.txSupplier().get()
tx.begin()
tx.findAssets(Query.builder().where('last_downloaded <').param(cutoffDate).build(), [repo]).each { asset ->
if (asset.componentId() != null) {
def component = tx.findComponent(asset.componentId())
if(component != null){
def count = tx.countComponents(Query.builder().where('name').eq(component.name()).and('version >').param(component.version()).build(), [repo])
if (count > 0) {
log.info("Delete asset ${asset.name()} as it has not been downloaded since 3 months and has a newer version");
// tx.deleteComponent(component)
}
}
}
}
tx.commit()