ARTIFACTORY: Execution of the artifactCleanup plugin may return a "No such property: size" error

ARTIFACTORY: Execution of the artifactCleanup plugin may return a "No such property: size" error

AuthorFullName__c
Elina Floim
articleNumber
000005586
ft:sourceType
Salesforce
FirstPublishedDate
2023-02-23T12:00:50Z
lastModifiedDate
2023-02-23T12:00:50Z
VersionNumber
1

Users running on Artifactory versions >=7.49.x and who had the artifactCleanup plugin installed on older Artifactory versions (prior to 7.49.x) will experience an error when executing the plugin, indicating that a ‘size’ property does not exist:

2023-02-22T13:25:00.003Z [jfrt ] [INFO ] [e8d7e6e1a68c8574] [artifactCleanup:173           ] [1a68c8574|art-exec-4] - Removing all artifacts not downloaded since 2023/02/22 13:22
2023-02-22T13:25:00.008Z [jfrt ] [ERROR] [e8d7e6e1a68c8574] [o.q.c.JobRunShell:211         ] [1a68c8574|art-exec-4] - Job artifactory.PluginCommand#82a173d3-4417-435e-9251-008b94c33f41 threw an unhandled Exception:
groovy.lang.MissingPropertyException: Exception evaluating property 'size' for java.util.ImmutableCollections$ListN, Reason: groovy.lang.MissingPropertyException: No such property: size for class: org.artifactory.model.common.RepoPathImpl
Possible solutions: file, id, name
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.getAtIterable(DefaultGroovyMethods.java:8761)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroovyMethods.java:8749)
    at groovy.lang.MetaClassImpl$6.getProperty(MetaClassImpl.java:2071)
    at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:63)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:329)
    at artifactCleanup$_artifactCleanup_closure4.doCall(artifactCleanup.groovy:213)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
.
.
.

This has been fixed in the latest plugin version, therefore, users encountering this error should proceed with the following steps:
  1. Retrieve the updated artifactCleanup.groovy plugin content and populate the existing groovy file with the new content, overriding the file’s existing content.
  2. Reload the plugin using the Reload Plugins REST API call. 
Upon a successful reload, the following entries should be logged in the artifactory-service.log:
2023-02-22T13:44:49.331Z [jfrt ] [INFO ] [44666eb1faf7af89] [o.a.a.p.PluginsAddonImpl:122  ] [http-nio-8081-exec-7] - Reloading plugins
2023-02-22T13:44:49.331Z [jfrt ] [INFO ] [44666eb1faf7af89] [o.a.a.p.GroovyRunnerImpl:263  ] [http-nio-8081-exec-7] - Script 'artifactCleanup.groovy' has changed. Reloading all scripts
2023-02-22T13:44:49.417Z [jfrt ] [INFO ] [44666eb1faf7af89] [o.a.a.p.GroovyRunnerImpl:315  ] [http-nio-8081-exec-7] - Loading script from 'artifactCleanup.groovy'.
2023-02-22T13:44:49.874Z [jfrt ] [INFO ] [44666eb1faf7af89] [.a.a.p.e.ExecutePluginImpl:189] [http-nio-8081-exec-7] - Groovy execution 'cleanup' has been successfully registered.
2023-02-22T13:44:49.876Z [jfrt ] [INFO ] [44666eb1faf7af89] [.a.a.p.e.ExecutePluginImpl:189] [http-nio-8081-exec-7] - Groovy execution 'cleanupCtl' has been successfully registered.
2023-02-22T13:44:49.877Z [jfrt ] [INFO ] [44666eb1faf7af89] [artifactCleanup:-1            ] [http-nio-8081-exec-7] - Schedule job policy list: [[cron:0 */5 * ? * *, repos:[example-repo-local], timeUnit:minute, timeInterval:3, dryRun:false, paceTimeMS:500, disablePropertiesSupport:true]]
2023-02-22T13:44:49.884Z [jfrt ] [INFO ] [44666eb1faf7af89] [o.a.a.p.j.JobsPluginImpl:95   ] [http-nio-8081-exec-7] - Groovy job 'scheduledCleanup_1' has been successfully scheduled to run.
2023-02-22T13:44:49.885Z [jfrt ] [INFO ] [44666eb1faf7af89] [o.a.a.p.GroovyRunnerImpl:359  ] [http-nio-8081-exec-7] - Script 'artifactCleanup' loaded.

In Artifactory running on a HA setup, the changes to the artifactCleanup.groovy file on one node should be propagated to the other nodes. Upon successful propagation, the following message should be logged in the artifactory-service.log:
2023-02-22T13:56:49.297Z [jfrt ] [INFO ] [                ] [p.HaPropagationServiceImpl:570] [e-watcher-notifier-1] - Propagation of artifactory/config/plugins/artifactCleanup.groovy to node art2 was successful