Under the regular UI defined jobs I can select "Do not fail build if archiving returns nothing". How do I achieve the equivalent in pipeline code?
E.g. currently I have something along these lines:
archive 'screenshots/**', 'build/test/results/*.xml'
and it is OK if there are no screenshots since there would be none if all tests pass.
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.
In Jenkins, an artifact is created in either Freestyle projects or Pipeline projects. In Freestyle, add the “Archive the artifacts” post-build step. In Pipeline, use the archiveArtifacts step.
Use the new archiveArtifacts
command, like this:
archiveArtifacts artifacts: 'screenshots/**,build/test/results/*.xml', allowEmptyArchive: true
Find the complete documentation of this command at https://jenkins.io/doc/pipeline/steps/core/#archiveartifacts-archive-the-artifacts
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