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?
Go to your client project and select configure. Create a post-build action and select 'archive artififacts' from the drop down menu. Add the type of files you want to archive (and eventually, copy and export).
You can use Ant-style pattern, e.g. target/*. jar to archive multiple artifacts. And it is possible to use a comma separated list of patterns if your files can't be matched with one pattern, e.g. target/*. jar, target/*.
By default, Jenkins archives artifacts generated by the build. These artifacts are stored in the JENKINS_HOME directory with all other elements such as job configuration files.
You could simply archive the complete workspace at the end of a build. It would then get deleted when the job is deleted. To do this: Add post-build action -> "Archive the artifacts"
To archive your entire folder in jenkins.
In your case let us say. If you want to archive complete "mydir" folder
**/my_dir/**
That is one way. If you have other folders with the same name. Then you can provide proper parent directory as well.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With