Skip to content

Commit c952fbd

Browse files
committed
create new plugin expireFileInRepos
1 parent a285921 commit c952fbd

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

download/ExpireFileInRemoteRepos/README.md renamed to download/ExpireFileInRepos/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ Artifactory expireFileInRemoteRepos User Plugin
22
====================================================
33

44
An implementation of the beforeDownloadRequest execution point. This
5-
plugin causes artifacts (including binaries) to expire and be re-cached when downloaded from a remote
5+
plugin causes artifacts (including binaries) to expire and be re-cached when downloaded from a remote/virtual
66
repository.
77

88
## Features
99

10-
To use the plugin, modify the script by adding the names of the remote repositories you wish to expire files in.
11-
The names are to be added to the list 'reposToExpire'
10+
To use the plugin, modify the script by adding the names of the repositories you wish to expire artifacts in.
11+
The names are to be added to the list 'reposToExpire'.
12+
Note: using this plugin, when downloading artifacts from virtual repositories - artifacts are expired and served from
13+
the source repo for all underlying repos
1214

1315
## Installation
1416

download/ExpireFileInRemoteRepos/expireFileInRemoteRepos.groovy renamed to download/ExpireFileInRepos/expireFileInRepos.groovy

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ final List<String> reposToExpire = List.of(/*TODO: add repo names*/)
2121

2222
download {
2323
beforeDownloadRequest { Request request, RepoPath repoPath ->
24-
if (reposToExpire.contains(repoPath.repoKey) && isRemote(repoPath.repoKey)) {
24+
if ((isRemote(repoPath.repoKey) || isVirtual(repoPath.repoKey))
25+
&& reposToExpire.contains(repoPath.repoKey)) {
2526
log.debug 'Repository ${repoPath.repoKey} is marked for file expiration. Expiring file: ${repoPath.name}'
2627
expired = true
2728
}
@@ -30,4 +31,8 @@ download {
3031

3132
def isRemote(String repoKey) {
3233
return repositories.getRemoteRepositories().contains(repoKey)
34+
}
35+
36+
def isVirtual(String repoKey) {
37+
return repositories.getVirtualRepositories().contains(repoKey)
3338
}

0 commit comments

Comments
 (0)