Image doesn't show in html file in the Jenkins workspace - jenkins

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.

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.

Related

Is there a way to add a link to a network folder?

I have a Jenkins job that runs a build. If build finishes sucessfully, it create a folder in the network with the installer package (it is not located in Job's workspace).
Is there a away to add a link to this installer package folder?
I've tried using Description Setter Plugin and Rich text publisher, link appears but nothing happens when pressing it.
** With a custom HTML page it works.

Jenkins could not generate HTML Report folder on slave-machine

I am trying to generate HTML reports(Protractor Test) through Jenkins but it says
"ERROR: Specified HTML directory 'x/y/z/Reports' does not exist". but when i run on the slave reports were generated.
What do i need to do on the Jenkins Configuration, please help on this.
*Path is correct but it could not generate "Reports" folder on the slave.
I am using- "protractor-html-screenshot-reporter"
You need specify the path like "\x\y\z\Reports\", and make sure those folders is existing on your slave-machine
This is the solution:
Click on Workspace Button and navigate until the HTML report folder appears.
Copy the full path (Even though it looks like it's before the project):
Paste the full path as is in the Publish HTML report plugin:
Remember! Location path / configuration on Bash script field (even running: cd /././. etc.) Does not affect the rest of the configuration settings on the Jenkins page.
This is why a full path is needed.

Using the Robot Framework plugin, how to copy files outside the log folder into Jenkins?

I am running Robot Framework tests through Jenkins, and the tests use a custom Python library to take screenshots, save them into a specific folder (that is not the log folder), and embed them into the log. In the Jenkins job, I have a post-build action set to publish the Robot results, and I can get Jenkins to copy image files that are generated within the log folder, but I can't figure out how to copy image files that are generated outside the log folder.
The project's %WORKSPACE% is d:\git\product\registration
The directory of Robot output is \log\patient_search (the log directory is generated inside the registration directory)
The directory where the other images are generated is d:\git\product\registration\verify\images
If I put *.png into the "Other files to copy" box, Jenkins will copy any images within the log\patient_search directory and they embed correctly into the log. What I have in that box now is *.png,%WORKSPACE%\verify\images\**, and I have tried using backslashes instead, using a relative path (..\..\verify\images\**\*.png), and various combinations of asterisks and slashes. Those images always show as broken links in the log.
Are these paths wrong, or can this just not be done for files outside of the log folder?
I believe Robot Framework plugin "Other files to copy" works only inside "Directory of Robot output". A workaround would be to create a build step where you execute a shell and copy files to Robot output directory.

Where is the copied artifact from the previous build saved

I have two jenkins jobs which are chained. The first job will run some testNG tests , in which we may get some failures. (A testng-failed.xml file will be generated that has all the tests that failed). In my second job, I need to run using that testng-failed.xml as my suite file. So I am using jenkins copy artifact plugin and saving the testng-failed.xml file. I am able to retrive it in the second job , where it says "Copied 1 artifact from "rerun_exp" build number 7".
But the problem is I dont know where it is saved to be used as my suite file.
You can easily check where the file is by looking in the workspace.
This can even be done directly from the Jenkins web UI, via the "Workspace" link in the sidebar of the job page.
Files matched by the "Artifacts to copy" field are copied to the same directory structure as the source build had.
You can use the "Flatten directories" option if you want the file(s) to be copied to the root of the build workspace. If you click the (?) help icon to the right of that checkbox, you can see documentation for this and for your original question.

Jenkins and SCP

I have set up a jenkins build and everything is working fine except the very last step.
The whole build creates a directory called: build
This directory contains a web-inf and all the files in it I would like to publish via SCP to a different location, so that all the content of the build/web-inf folder will become the content of the target folder.
The settings for jenkins scp plugin are (it is a post-build step):
source: build/web-inf/**
destination: public_html/
that results in:
public_html/build/web-inf/...
but should be:
public_html/...
(the keep hierarchy box is ticked)
how can I make that happen??
EDIT
I could solve the problem without any additional script. The solution is so simple that my question turned out to be stupid.
All I did was telling ant to copy all the webfiles to ./public_html instead of ./build/web-inf/ what made the jenkins scp copy all files from public_html to public_html exactly as it was intended to.
If your goal is just to SCP files generated during the build, and the plugin doesn't seem to be working (I couldn't see anything wrong in your configuration) you can use an "Execute shell" build step and type the scp command something like (try it in a shell first in your job's build directory to get the syntax right):
scp -r build/web-inf/* user#host:/destination-directory

Resources