My jenkins job creates a temporary subfolder, say "mydir", within the workspace that I then want to archive using the postbuild step "Archive artifacts".
I'm using the following command:
mydir/**/*
It works well but the archive will always contains mydir as the root of the artifacts whereas I would like to have the contents of this folder only.
How to do this?
You can use dir()
to archive the artifact from inside the desired directory:
stage('Archive') {
steps {
dir('mydir') {
archiveArtifacts artifacts: '**'
}
}
}
https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#dir-change-current-directory