Issue
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?
Solution
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.
Answered By - Prostagma
Answer Checked By - Pedro (JavaFixing Volunteer)