ARTIFACTORY: How to keep the Empty Folders in the Repositories?
DescriptionBy default, empty folders in the repository are dropped, since there is a global job in the background that triggers pruning. This job is controlled by two parameters, and the default values are:
artifactory.folderPruning.intervalSecs=300 artifactory.folderPruning.quietPeriodSecs=60
“artifactory.folderPruning.intervalSecs=300” means that clean-up tasks are performed every 300 seconds.
“artifactory.folderPruning.quietPeriodSecs=60” indicates an empty directory that has not changed in 60 seconds will be pruned.
How to keep the Empty Folders for a long time?If you want to keep empty folders for a long time, you can set them to a large number in $JFROG_HOME/artifactory/etc/artifactory/artifactory.system.properties file, like: 31536000 means 365 days.
artifactory.folderPruning.intervalSecs=31536000 artifactory.folderPruning.quietPeriodSecs=31536000
How to check pruning behavior with logs?Should add the following settings in the $JFROG_HOME/artifactory/var/etc/artifactory/logback.xml file. Do not need to restart Artifactory.
<appender name="cleanupfolder" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${log.dir}/cleanup-folder.log</File>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.jfrog.common.logging.logback.layout.BackTracePatternLayout">
<pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSS, UTC}Z %boldGreen([jfrt ]) %highlight([%-5p]) [%-16X{uber-trace-id}] [%-30.30(%c{3}:%L)] [%-20.20thread] - %m%n</pattern>
</layout>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>${log.dir.archived}/cleanup-folder.%i.log</FileNamePattern>
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>25MB</MaxFileSize>
</triggeringPolicy>
</appender>
<logger name="org.artifactory.repo.cleanup.FolderPruningServiceImpl">
<level value="debug"/>
<appender-ref ref="cleanupfolder"/>
</logger>
This will immediately give you the indication that we are offering the job with the promoted empty folders, like:
2023-03-13T08:39:41.267Z [jfrt ] [DEBUG] [c2acf84e5d135ab2] [c.FolderPruningServiceImpl:183] [5d135ab2|art-exec-13] - Pruning empty folder 'example-repo-local:oem/upgrade' 2023-03-13T08:39:41.272Z [jfrt ] [DEBUG] [c2acf84e5d135ab2] [c.FolderPruningServiceImpl:171] [5d135ab2|art-exec-13] - Added folder repo path 'example-repo-local:oem' to pruning queue. 2023-03-13T08:39:46.264Z [jfrt ] [DEBUG] [8b6122c67e22ae24] [c.FolderPruningServiceImpl:183] [67e22ae24|art-exec-7] - Pruning empty folder 'example-repo-local:oem'