2
votes

My build job produces various artifacts, they are based on parameters but not directly computable from them. The artifacts are undetermined until the build steps complete. Upon build steps completion, the newly created artifacts' file names are located in the designated file (known in advance)

I want to archive the artifacts by specifying their file names in that file. How can I do it?

P.S. From what I know, the "Archive the artifacts" step specs are similar to includes attribute of Ant fileset. I need something like includesfile.

2

2 Answers

2
votes

You can read the file with the readFile step, and convert it to the format expected by archiveArtifacts (comma-separated String of items). E.g.:

String artifacts = readFile(file: 'artifacts.txt').split('\n').join(',')
archiveArtifacts artifacts
0
votes

I was able to workaround the issue:

  1. Add post-build script step (before archiving artifacts). In it: iterate over file names in the file, copy each to the designated (empty) folder
  2. Configure the Archive artifacts step to take all files from that designated folder.