I'm using the Cucumber Reports Plugin for Jenkins and I want to be able to export the HTML reports so they can be posted on an external portal. I can see that there is a folder named cucumber-html-reports
in the build directory in Jenkins, but how do I access this? Is there some way to access these files from within a pipeline?
-
Many Thanks for your response. May I know how to execute this code as in whether i have to feed it in jenkins job or i have to create a file with any specific extension and run? node('master') { dir("../builds/${BUILD_NUMBER}/") { sh "cp -r cucumber-html-reports $WORKSPACE" } archive "cucumber-html-reports/*" } Please help– Ankit SuhaneCommented Jan 17, 2019 at 16:15
-
@AnkitSuhane That script is a Jenkins scripted pipeline (jenkins.io/doc/book/pipeline/syntax/#scripted-pipeline), but it could be executed as a Shell step and an Archive step in a regular freestyle build.– lawnmowerlatteCommented Mar 12, 2019 at 3:44
2 Answers
Working off what @chupasaurus said, here's what I came up with:
node('master') {
dir("../builds/${BUILD_NUMBER}/") {
sh "cp -r cucumber-html-reports $WORKSPACE"
}
archive "cucumber-html-reports/*"
}
Obviously all this does is archive the report for that build, but you can easily extend this to copy it somewhere else where it can be hosted or manipulated. Just make sure you put this after the Cucumber Reports plugin step.
You should add export script (bash script which does exporting html files produced to the place they belong) after Cucumber Reports plugin step, as it should be used by job runned either solely or by pipeline.