Jenkins HTML publishing on build level without copies

1,189 views
Skip to first unread message

Filip Kosik

unread,
Apr 1, 2020, 1:32:12 PM4/1/20
to Jenkins Users
Hi,

I am trying to publish HTML reports for each build. I tried plugin HtmlPublisher (1.22) but when it publishes my reports on their build page (using keepAll=true), it creates copies of reports from all previous builds in each build directory. So, each Jenkins build includes many copies of old reports and they are bigger and bigger. If I publish my reports on the project page (using keepAll=false), old reports are preserved in their project directory (in my file system) but only the last report is accessible from Jenkins. Is there any way how to have reports on their build pages without creation of their duplicates? Maybe, there is some parameter that I'm still missing.


My pipeline includes the following HtmlPublisher use:


publishHTML (target: [
  allowMissing: false,
  alwaysLinkToLastBuild: false,
  keepAll: true,
  reportDir: "./htmlReports",
  reportFiles: reportFileNames, //generic variable
  reportName: "Results"
])
 

Thank you

Gianluca

unread,
Apr 1, 2020, 2:46:35 PM4/1/20
to Jenkins Users
Hi, I have this in my pipeline

publishHTML target: [
allowMissing: true,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'out/python3-cov',
reportFiles: '*/index.html',
reportName: 'Python 3 Coverage'
]


And I don't have old reports in builds. Each build has it own report built.

So, or I don't understand what you are asking for, or you misunderstood the behaviour? 

Can you details more what you mean with duplications?

Filip Kosik

unread,
Apr 1, 2020, 3:20:56 PM4/1/20
to Jenkins Users
Hi Gianluca,

thank you for your answer. Here is an example of my problem:

When I run pipeline code:
def fileName = "index_${reportBuildNo}.html";
… // HTML is generated here

publishHTML (target: [
      allowMissing: false,
      alwaysLinkToLastBuild: false,
      keepAll: true,
      reportDir: "/${reportDir}",
      reportFiles: fileName,
      reportName: "Results"
    ])
my build directories after 3 builds contains the following:
build/1/htmlreports
 - index_1.html
build/2/htmlreports
 - index_1.html
 - index_2.html
build/3/htmlreports
 - index_1.html
 - index_2.html
 - index_3.html

Maybe the problem is in my generic report filenames (including build number).
My old and new HTML files are generated into one directory for all builds. When HTML files are generated I pass only filenames of the current build to htmlPublisher.

Gianluca

unread,
Apr 1, 2020, 3:27:40 PM4/1/20
to Jenkins Users
Hi,
I think you misunderstood the meaning of
reportDir: "/${reportDir}",

The publishHTML publishes the directory ... not the file. The reportFiles is the "index" that is loaded as beginning but it's the reportDir with whole is content that is published by the plugin.

So, you can't have a reportDir that's shared across builds or everything will be published for all builds getting duplicates.

I'm not sure why do you need the build number in the index file, Jenkins publishHTML plugin already put the generated files into separated builds directory as you already found out by looking at the reportDirs.

So, I would suggest to rethink your strategy of building reports and avoid file names with build number into it.

Cheers,
Gianluca.

Filip Kosik

unread,
Apr 1, 2020, 3:41:19 PM4/1/20
to Jenkins Users
Thanks Gianluca for your explanation.
This is exactly my problem. So, there is no way how I can publish only specific files without archiving all files in directory?

The reason for the build number in my filenames is generating all HTML files to the shared directory (it is not inside build directory). It's not index (it was only example) and it's used for another purpose. So, if there is no way how publish and archive only specific files, I would make a fork of the plugin and change it by myself. 

Thank you for help.
Filip

Richard Bywater

unread,
Apr 1, 2020, 7:51:40 PM4/1/20
to jenkins...@googlegroups.com
Yes there is - use "includes" parameter which is an Ant compatible pattern that specifies what files in the report directory to archive. It defaults to archiving all files in the given report directory.

Richard.


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9ae3a26c-3f76-44e6-947b-3cdff8140cf4%40googlegroups.com.

Filip Kosik

unread,
Apr 2, 2020, 12:29:33 PM4/2/20
to Jenkins Users
Awesome, that is what I was looking for. Thank you.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkins...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages