Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cleanup/artifactCleanup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Parameters
- `months`: **Deprecated**. Instead of `timeUnit` and `timeInterval` the `month` parameter is supported for backwards compatibility reasons. It defined the months to look back before deleting an artifact. Default *1*.
- `timeUnit`: The unit of the time interval. *year*, *month*, *day*, *hour* or *minute* are allowed values. Default *month*.
- `timeInterval`: The time interval to look back before deleting an artifact. Default *1*.
- `repos`: A list of repositories to clean. This parameter is required.
- `repos`: A list of repositories to clean. Use keyword "__all__" to cleanup all. Default *"__none__"*
- `dryRun`: If this parameter is passed, artifacts will not actually be deleted. Default *false*.
- `paceTimeMS`: The number of milliseconds to delay between delete operations. Default *0*.
- `disablePropertiesSupport`: Disable the support of Artifactory Properties (see below *Artifactory Properties support* section). Default *false*.
Expand Down
11 changes: 8 additions & 3 deletions cleanup/artifactCleanup/artifactCleanup.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@ def configFile = new File(ctx.artifactoryHome.etcDir, CONFIG_FILE_PATH)
if ( deprecatedConfigFile.exists() ) {

if ( !configFile.exists() ) {
def config = new ConfigSlurper().parse(deprecatedConfigFile.toURL())
def config = new ConfigSlurper().parse(deprecatedConfigFile.toURI().toURL())
log.info "Schedule job policy list: $config.policies"

def count=1
config.policies.each{ policySettings ->
def cron = policySettings[ 0 ] ? policySettings[ 0 ] as String : ["0 0 5 ? * 1"]
def repos = policySettings[ 1 ] ? policySettings[ 1 ] as String[] : ["__none__"]

if (repos[0] == "__all__"){
repos = null
}

def months = policySettings[ 2 ] ? policySettings[ 2 ] as int : 6
def paceTimeMS = policySettings[ 3 ] ? policySettings[ 3 ] as int : 0
def dryRun = policySettings[ 4 ] ? policySettings[ 4 ] as Boolean : false
Expand All @@ -128,7 +133,7 @@ if ( deprecatedConfigFile.exists() ) {

if ( configFile.exists() ) {

def config = new JsonSlurper().parse(configFile.toURL())
def config = new JsonSlurper().parse(configFile.toURI().toURL())
log.info "Schedule job policy list: $config.policies"

def count=1
Expand Down Expand Up @@ -168,7 +173,7 @@ private def artifactCleanup(String timeUnit, int timeInterval, String[] repos, l

calendarUntil.add(mapTimeUnitToCalendar(timeUnit), -timeInterval)

def calendarUntilFormatted = new SimpleDateFormat("yyyy/MM/dd HH:mm").format(calendarUntil.getTime());
def calendarUntilFormatted = new SimpleDateFormat("yyyy/MM/dd HH:mm").format(calendarUntil.getTime())
log.info "Removing all artifacts not downloaded since $calendarUntilFormatted"

Global.stopCleaning = false
Expand Down
7 changes: 4 additions & 3 deletions cleanup/deleteEmptyDirs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ paths.
Parameters
----------

This plugin takes one parameter, called `paths`, which consists of a
comma-separated list of paths to search for empty directories in. Each path is
in the form `repository-name/path/to/dir`.
This plugin takes two parameters, called
`paths`, which consists of a comma-separated list of paths to search for empty directories in (each path is
in the form `repository-name/path/to/dir`, use keyword "__all__" to check all repositories) and
`cron`, which is a string containing cron syntax schedule to run this plugin (Default *"0 0 5 ? * 1"*).

Executing
---------
Expand Down
23 changes: 21 additions & 2 deletions cleanup/deleteEmptyDirs/deleteEmptyDirs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,36 @@ executions {
}
}

def config = new ConfigSlurper().parse(new File(ctx.artifactoryHome.etcDir, PROPERTIES_FILE_PATH).toURL())
private def insertAllRepositories(ArrayList paths) {
repositories.getLocalRepositories().each {
paths.add(it)
}

repositories.getRemoteRepositories().each {
paths.add(it)
}

repositories.getVirtualRepositories().each {
paths.add(it)
}
}

def config = new ConfigSlurper().parse(new File(ctx.artifactoryHome.etcDir, PROPERTIES_FILE_PATH).toURI().toURL())
log.info "Schedule job policy list: $config.policies"

config.policies.each{ policySettings ->
def cron = policySettings[ 0 ] ? policySettings[ 0 ] as String : ["0 0 5 ? * 1"]
def paths = policySettings[ 1 ] ? policySettings[ 1 ] as String[] : ["__none__"]

if (paths[0] == "__all__") {
paths = []
insertAllRepositories(paths)
}

jobs {
"scheduledDeleteEmptyDirs_$cron"(cron: cron) {
log.info "Policy settings for scheduled run at($cron): path list($paths)"
deleteEmptyDirectories( paths )
deleteEmptyDirectories( paths as String[])
}
}
}
Expand Down