ARTIFACTORY: How to forcefully delete a build from Artifactory UI
Issue description:
In some rare cases, when the build info file was corrupted or deleted from the file store, it is impossible to delete the build from the UI. (RTFACT-21101)
Resolution steps:- Enable force saving a build if it exists in the DB already, by adding the system property below to artifactory.system.properties (under $JFROG_HOME/artifactory/var/etc/artifactory) and restart Artifactory:
artifactory.builds.db.force.override.enabled=true
- The next steps will be to create JSON content that will mimic the original build-info.json file. For that, you will need to try and delete the build and get a warning message in the artifactory-service log:
2022-03-22T12:14:47.267Z [jfrt ] [WARN ] [7336e8415738eb58] [o.a.s.f.l.SessionLockEntry:134] [http-nio-8081-exec-7] - Mutable item 'artifactory-build-info:maven-example-2/104-1632391567030.json' has local modifications that will be discarded.
- The original json file as seen in the above entry is named as <buildname>/<build-number>-<timestamp>.json (timestamp is in epoch time) and we will need all 3 parameters.
In the above example, the build name is “maven-example-2” the build number is “104” and the timestamp is “1632391567030”
For simplicity, the timestamp parameter can be retrieved from the UI under the "Build Time" tab, however it should modified according to this format:
yyyy-MM-dd'T'HH:mm:ss.SSSZ
(note that the milliseconds will not show in the UI, they are the last 3 numbers in epoch time) - Lastly, deploy the build info using the REST API which will override the existing missing build and will allow it to be deleted:
curl -X PUT "http://localhost:8081/artifactory/api/build" -H "Content-Type: application/json" -d '{ "name" : "maven-example-2", "number" : "104", "started" : "2021-09-23T13:06:07.030+0300" }' -uadmin:passwordNote that the ".030" is taken from the original filename (104-1632391567030.json) and the "+0300" is the same as seen in the UI.
In the ‘artifactory-service.log’ you can also see that the build was overridden, e.g:2022-03-22T13:07:54.623Z [jfrt ] [INFO ] [4703c4daebcba9a1] [a.r.i.BuildInfoInterceptor:105] [http-nio-8081-exec-5] - Override of build at path 'artifactory-build-info/maven-example-2/104-1632391567030.json' detected.
- Remove the added system property from ‘artifactory.system.properties’ file and restart Artifactory.