Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Add artifact archive to jenkins pipeline

Angelika Ehlers edited this page Oct 2, 2017 · 7 revisions

Issue:

Need to archive test results or other files

Solution:

Add an archive stage to your pipeline. Example:

// Archive the built artifacts

archive (allowEmptyArchive: true, includes: 'report/*.html')

Even better wrap your archive in a try/catch block:

try { <your stage steps> } finally { archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/**/*' }

Note:

Archive will show only after the job is finished. I.e. if the job waits for input the archive does not show. There is a trick to get around this by copying the files to be archived in a new folder in the workspace.

 dir ('BDDreports') {
   sh 'ls -l'
   writeFile file:'ReadMe.txt', text:'BDD Test Results Folder'
   sh 'cp reports/* BDDreports/'
   sh 'ls -l'
 }
Clone this wiki locally