Wednesday, 8 July 2020

Save artifacts in Jenkins Pipeline

Advocacy and Outreach

Built artifacts from Jenkins can be downloaded for local analysis and investigation, in case of tests failures. This can be achieved thanks to Jenkins’s built-in support for storing "artifacts", that is files generated during the execution of the Pipeline.


This is easily done with the archiveArtifacts step and a regex expression.

dir/**/*.*    -> archive all the files recursively under dir/

**/*.*                 -> archive all the files in the workspace

**/*.xml      -> archive all xml files in your workspace

dir/**/*.xml     -> archive all the xml files recursively under dir/



For example, if in your build a .dev file is created, then you can archive it doing:


 stage('Archive Artifacts'){

    archiveArtifacts artifacts: '**/*.dev'

 }



Then you can download it directly from Jenkins Web Console:



If you want to check the files on Jenkins server filesystem, then you can locate the artifacts in:
$JENKINS_HOME/jobs/<job_name>/builds/<build_number>/archive



No comments:

Post a Comment