Issue
My file tree is as follows:
Jenkins > workspace > <JOB_NAME> > out > <BUILD_NAME> /
In the <BUILD_NAME> directory, there are a bunch of files of differing extensions, such as .hex, .map and .zip. Additionally, there is another subdirectory - build. I want to archive all individual files, but not the contents of build/. What is the most efficient way to do this in a declarative pipeline? Keep in mind that the name of <BUILD_NAME> changes constantly, so it can't be hardcoded into the archive path.
Solution
It is possible to archive the artifacts with archiveArtifacts
step. The step provides option for excluding files from archiving.[1]
archiveArtifacts artifacts: '${JOB_NAME}/out/${BUILD_NAME}/*', excludes: '${JOB_NAME}/out/${BUILD_NAME}/build/*'
I assume that BUILD_NAME
is a variable or parameter you defined, since it is not a global variable. See [2] for global variables.
[1] https://www.jenkins.io/doc/pipeline/steps/core/#archiveartifacts-archive-the-artifacts
[2] https://opensource.triology.de/jenkins/pipeline-syntax/globals
Answered By - Melkjot