Reputation: 95
I am using the following code to download files from Artifactory using PowerShell.
#example Artifactory url
$artifactory_url = "https://artifactory.company.com/artifactory/"
#example Artifactory Key
$ArtifactoryKey = "<artifactory key>"
$wc = New-Object System.Net.WebClient
$wc.Headers.Add("X-JFrog-Art-Api", $ArtifactoryKey)
$files = @("test1.zip", "test.zip")
try {
foreach($file in $files) {
$wc.DownloadFile("$artifactory_url/$file", "D:\download\$file")
}
}
catch {
$Host.UI.WriteErrorLine("Error while Trying to download Artifacts.")
$Host.UI.WriteErrorLine($_.Exception.Message)
exit
}
I now have a repository on Artifactory that has couple of recursive folders with files. So I need to download all contents of that repository.
What do I need to change in my code above to achieve that?
Upvotes: 2
Views: 3807
Reputation: 1511
To download the entire folder under a repository you can utilize the JFrog CLI. First, configure the Artifactory with the JFrog CLI and download the entire folder as below,
$ jfrog rt dl "my-local-repo/*.jar" all-my-frogs/
Upvotes: 5