Skip to content

Commit

Permalink
Add properties to file in archive after added in source (kudos to @as…
Browse files Browse the repository at this point in the history
…chbacd)

Required for docker / gems client, etc.
  • Loading branch information
Florian Begusch committed Apr 28, 2021
1 parent af595f7 commit daa2089
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions storage/remoteBackup/remoteBackup.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,30 @@ storage {
}
}
}

afterPropertyCreate { item, name, values ->
def etcdir = ctx.artifactoryHome.etcDir
def cfgfile = new File(etcdir, REMOTE_BACKUP)

// Ensure invalid or missing JSON config does not prevent Artifactory
// from serving and receiving artifacts.
//
cfg = parseJson(cfgfile)
if (!cfg) return

if (item.repoKey in cfg && !item.isFolder() && name != "artifactory.internal.etag") {
asSystem {
def dest = cfg[item.repoKey]
try {
// Set property in archive repo
def destpath = RepoPathFactory.create(dest, item.relPath)
repositories.setProperty(destpath, name, values)
} catch (Exception ex) {
log.warn("Unable to set property $name for $destpath: $ex.message")
}
}
}
}
}

def runBackup(repos) {
Expand Down

0 comments on commit daa2089

Please sign in to comment.