Closed idcmp closed 7 years ago
Thank you for letting us know about this issue. I can't seem to reproduce this ... it cleans fine for me with or without a maven-metadata.xml. What behavior are you experiencing? When it aborts, does it just stop cleaning prematurely and act like it finished successfully, or does it give any sort of error or stacktrace? Also, what version of Artifactory are you running?
Thanks for taking a look! We're on Artifactory Professional 4.11.0 rev 40239. I'm running the plugin via the REST API, authing as a user with full admin access:
-X POST "http://artifactory.example.net:8081/artifactory/api/plugins/execute/cleanup?params=months=8|repos=our-plugin-snapshots,our-snapshots,third-party-snapshots|paceTimeMS=85"
This will run for a while then return:
HTTP/1.1 404 Not Found
Server: Artifactory/4.11.0
X-Artifactory-Id: ...
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 02 Sep 2016 16:26:24 GMT
{
"errors" : [ {
"status" : 404,
"message" : "Item our-snapshots:com/example/coolthing/our-artifact/1.2-SNAPSHOT/maven-metadata.xml does not exist"
} ]
If I take the error message and perform a /api/maven/calculateMetadata/ and rerun the cleaner, it will progress past that artifact the next time I run it until it stumbles on the next problem.
(I can presently reproduce this, so if there's something you'd like me to look at, let me know.)
So what it looks like to me is, the initial artifact search is finding a maven-metadata.xml file, but by the time it gets around to cleaning that file, it's already gone. So either the search system is finding a file that doesn't exist, or the file does exist and is being deleted in the middle of the cleanup by something else. I don't really know why this would be happening, although I would imagine it has something to do with the way this file in particular is generated/handled.
In any case, I've pushed an update that should fix the problem. The way I see it, if you want to delete an artifact but it doesn't exist, that just means the work has already been done for you. So now when the plugin can't find an artifact, it just ignores it and moves on to the next one.
Please let me know if this helps.
Hi, im also artifactory pro user and i just tried your updated cleanup Skript.
Unfortunately it shows the same behaviour.
{code}
{
"errors" : [ {
"status" : 404,
"message" : "Item
The skript has to be run for every single Version cause it aborts after every deletion.
So i suggest your fix is not working.
BTW: Is it possible to delete empty folders too?
This whole API Groovy Plugin thing is not very satisfying, i spent hours to schedule some jobs that fix our free disk space problems just realizing that dryRun works and the realRun doesn't.
Hi heinzepreller,
That seems very strange that the updated script is still giving that error, since it catches said error everywhere it might be thrown. If you replaced an older version of the plugin on your instance, it's possible that it wasn't reloaded by Artifactory properly. By default, added or modified plugins are not loaded automatically, and you have to either use the reload plugins REST call, or restart Artifactory. If you can confirm that you are using the correct version of the plugin, and that it was loaded properly by Artifactory, then I would suggest checking for a stacktrace in your artifactory.log
file (you may need to change the plugin's log level first). That should provide more information about what's going on.
BTW: Is it possible to delete empty folders too?
Yes, this can be done with the deleteEmptyDirs user plugin.
I've found out how to reproduce this issue. I had to modify the plugin to sort the list of artifacts before deleting them, so that jar and pom files are always deleted after the maven-metadata.xml
files that describe them. Without this, the order of deletion is indeterminate, but the issue only appears when the metadata files are deleted last.
From this, I can determine the most probable cause. The following steps occur:
maven-metadata.xml
file exists, generated by Artifactory at some point.maven-metadata.xml
file.maven-metadata.xml
file in turn.maven-metadata.xml
file, but can't find it, and 404s.This issue existed in the previous version of the plugin, but is fixed in the commit I mentioned a few days ago. So assuming it's the same issue that you're having (most likely), it should be fixed for you as well.
thx for answering DarthFennec, i'll try that.
Closing for inactivity. This appears to be resolved, but if not don't hesitate to reopen.
When running dryRun=true, the cleanup lists the work it would do. When running without dryRun, if a project is missing a maven-metadata.xml (lets say from a failed deploy), the script will abort.
I can generate the metadata for an individual artifact by POSTing to /api/maven/calculateMetadata/..repoId../..groupId../..artifactId.. However, I wind up needing to do this for every artifact in a multimodule project to get the cleanup to work.
The groovy script: https://github.com/JFrogDev/artifactory-user-plugins/blob/master/cleanup/artifactCleanup/artifactCleanup.groovy