I'm trying to configure HTML Publisher plugin for Jenkins via Jenkinsfile to publish few html files like this:
publishHTML(
target: [
allowMissing : false,
alwaysLinkToLastBuild: false,
keepAll : true,
reportDir : 'my-project-grails/build/reports/codenarc',
reportFiles : 'test.html',
reportName : "Codenarc Report"
]
)
The description of the reportFiles
parameter here says I should be able to specify multiple files. But what's the syntax?
The HTML Publisher plugin can be configured in the post build portion of your Jenkins job. HTML directory to archive - the path to the report directory to archive relative to the workspace. Index page[s] - comma-seperated list of files that will be used as index pages. Ant patterns can be used.
As Sebien's answer but:
script
blockpublishHTML([
reportName: 'Newman Report'
reportDir: 'reports',
reportFiles: "${dir('reports') { findFiles(glob: '**/*.html').join(',') ?: 'Not found' }}",
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
])
If you have several HTML files but do not know their name nor count in advance, you can do such code:
script {
def htmlFiles
dir ('reports') {
htmlFiles = findFiles glob: '*.html'
}
publishHTML([
reportDir: 'reports',
reportFiles: htmlFiles.join(','),
reportName: 'Newman Collection Results',
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true])
}
Notice the script
section as Jenkins does not allow to declare variable in stage
or steps
section.
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