Reputation: 3
This snipped
stage('get iter number') {
steps {
rtDownload ( //
serverId: 'MAIN-ARTIFACTORY',
spec: '''{ "files": [{"pattern": "p1/p2/p3/${BUILD_ID}/n_iter.txt", "target": "./n_iter.txt"}] }''',
)
}
}
where BUILD_ID = 'a/b' downloads file to a location $WORKSPACE/p2/p3/a/b/n_iter.txt rather then expected $WORKSPACE/n_iter.txt
Also, very strange - why p1 is not in downloaded path?
Upvotes: 0
Views: 5108
Reputation: 1861
By default, artifacts are downloaded to the target path in the file system while maintaining their hierarchy in the source repository (not including the repository name - hence p1
is missing in your example).
To download an artifact while ignoring the hierarchy, set "flat": "true"
in your file spec.
For a more advanced control of the resulting hierarchy, you may want to use Placeholders.
See more information in the File Specs documentation.
Upvotes: 1
Reputation: 46
Please try with the below snippet, which means all the files in the com/my-files/ Artifactory repository-path will be downloaded into the my-folder directory on the Jenkins agent file system. For more details on this please do refer to our Declarative Pipeline Syntax wiki page here.
rtDownload (
serverId: 'Artifactory-1',
spec: '''{
"files": [
{
"pattern": "com/my-files/",
"target": "my-folder/"
}
]
In addition to the above, you can refer to the rtDownload example referred to in our GitHub page here.
Upvotes: 0