0
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at BUILD level /home/jenkins/workspace/awesome-integration-into-jenkins/mochawesome-report to 
/var/jenkins_home/jobs/IDE/jobs/ide-application/branches/subtask-I.anjt14c4kifi.o-jenkins/builds/5/htmlreports/Mochawesome_20Report

This output is obtained after running:

post {
    always {
        sh 'rm mochawesome-report/mochawesome.json'

        publishHTML (target: [
            allowMissing: false,
            alwaysLinkToLastBuild: true,
            keepAll: true,
            reportDir: "$WORKSPACE/mochawesome-report/",
            reportFiles: 'mochawesome.html',
            reportName: "Mochawesome Report"
        ])

        cleanWs()
    }
}

I am using htmlpublisher to publish test report after all steps in the pipeline are complete. As can be seen from the output, the files are copied to var/jenkins_home/jobs/IDE/jobs/mosaiq-ide-application/branches/subtask-I.anjt14c4kifi.o-jenkins/builds/BUILDNUMBER/. There is no setting in htmlpublisher that allows the user to delete old report folders. Is there a plugin that I can use in the post pipeline step that looks inside the ..../builds/BuildNumber/htmlreports folder and checks if it is x days old, and removes it. Or how can I efficiently achieve the desired result?

Ankit Koirala
  • 354
  • 3
  • 13
  • All the old artifacts are deleted with the build that created them. You can configure max number of builds or max days to keep them. The idea is that you either need *both* the build and its artifacts, or you need none of them. There is no option to erase specific files, I'm afraid. – MaratC Dec 19 '19 at 16:38
  • @MaratC The htmlpublisher plugin copies the given html folder to a separate location, such that when cleanWs() is performed, those html files are not deleted. Is it possible to set an expiration time for those files. How do I make the max number of builds or max configuration work? – Ankit Koirala Jan 08 '20 at 13:19
  • See https://stackoverflow.com/a/44155346/2047614. – MaratC Jan 08 '20 at 13:35

0 Answers0