Issue
I am running a Jenkins job which generates png files, and html files.
Image files are stored in a specific directory, and html files in another directory.
Html files contain img
tags which src
attributes to the image files locations.
When I run the project on my Ubuntu machine, I can see the images in the html files. It looks like <img src='../screenshots/screenshotname.png'/>
However, when I run the same project on Jenkins, and then open the html file while browsing the Jenkins workspace, the img doesn't show. There's a "broken image" icon. If I change the src
attribute using the inspector and put the absolute path of the image, the image doesn't show either.
But if I download the whole workspace and open the html file, the image shows well.
Do you have an idea of why this behavior occurs? Is it because of a Jenkins configuration?
Thank you very much.
Solution
I believe you are using some plugin like publish html to publish html report. The reason is jenkins does not support any css by default. So you have to break the rule.
Manage Jenkins--Manage Nodes--Click settings(gear icon)-- click Script console on left and type in the following command:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
Click run and once you run you will see Result below, it will empty space. Now go back to pipeline and build it. Now you will be able to view the reports as you want.
Answered By - Aniket Kumar
Answer Checked By - Mary Flores (JavaFixing Volunteer)