How to solve,  Opening Robot Framework log failed  Issue in Jenkins

How to solve, Opening Robot Framework log failed Issue in Jenkins


How to solve, Opening Robot Framework log failed Issue in Jenkins

Solution: Robot Framework Logs are not Opening in Jenkins

Script Console:
System.setProperty(“hudson.model.DirectoryBrowserSupport.CSP”,“sandbox allow-scripts; default-src ‘none’; img-src ‘self’ data: ; style-src ‘self’ ‘unsafe-inline’ data: ; script-src ‘self’ ‘unsafe-inline’ ‘unsafe-eval’ ;“)

Jenkins.xml changes:
Add -Dhudson.model.DirectoryBrowserSupport.CSP="" in argument tag in jenkins.xml

The argument tag should look like:
Note- Please replace the # with angle brackets in following line.
#arguments#-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dhudson.model.DirectoryBrowserSupport.CSP="" -jar “C:\Program Files\Jenkins\jenkins.war” —httpPort=8080 —webroot=“%LocalAppData%\Jenkins\war”#/arguments#


Content

0.68 -> Hi guys welcome back, If you are not able to see Robot Framework
4.441 -> logs on Jenkins, Don't worry, we are going to solve that issue
8.83 -> with a permanent fix, But before I start the video I would request you to subscribe to
14.1 -> this channel.
15.68 -> Because when you subscribe and like this video, you really help us grow on YouTube.
20.34 -> And it also encourages us to make more such videos in future for you.
27.35 -> So to start with the video, lets understand how did I land up on this page.
32.41 -> This is a simple Jenkins job that I have created for the demo and you can see few logs are
37.91 -> already generated over here.
39.79 -> And if you open these logs now.
42.67 -> You get this error.
43.92 -> Not to fix this error, lets understand what does it mean?
49.21 -> Basically when you execute robot framework testcases, it will generate some HTML files
57.079 -> as logs. and that HTML file content is not allowed on Jenkins.
62.01 -> It contains some java script and some stuff, which is not allowed on Jenkins. because Jenkins
69.52 -> see it as security risk.
72.45 -> Jenkins content security policy does not allow you to print the Robot Framework logs.
77.58 -> And you want to see the Robot Framework logs on Jenkins, you will have to modify the Content
82.12 -> Security Policy of Jenkins.
83.66 -> Now before I discuss the different ways to modify the Content Security Policy.
89.07 -> I would recommend you to discuss this with your dev ops guys or your security team.
95.88 -> So that... you know...
97.54 -> You are going to modify the security policy, if your Jenkins is publicly facing then you
104.32 -> better check with them.
105.72 -> if it is secure enough, If it is behind firewall or if it is your private Jenkins, then you
112.39 -> can probably go ahead and modify the content security policy.
118.88 -> To modify the Content Security Policy, lets go to..
124.13 -> Manage Jenkins.
127.79 -> And just find the script console. where I will be executing few scripts to modify content
135.629 -> security policy.
136.629 -> These scripts are mentioned in the description.
138.87 -> so you don't need to note it down.
141.87 -> Ok? so I have executed it.
145.43 -> Now If I go and refresh the page, I can see the logs, Great!.
149.26 -> But the problem with this approach is..
152.999 -> If you restart the Jenkins service these settings will go away.
162.919 -> Lets say..
175.79 -> Refresh...
182.23 -> Ok..
188.67 -> See the logs are not showing up again.
191.689 -> so issue is reproduced.
192.919 -> Now how to fix this issue in permanent way.
198.51 -> For that you need to find the Jenkins installation directory.
202.31 -> which is in program files.
204.64 -> And then here you can see Jenkins.xml. open that file and you will have to add this system
213.569 -> property, before the jar, before you execute the jar.
221.73 -> I have already done these changes here.
225.849 -> And this is also mentioned in the description.
229.359 -> Ok?
231.729 -> So what does this basically means, you are setting content security policy of Jenkins
237.43 -> to blank string.
239.859 -> this basically allows every thing.
242.479 -> Every content on the Jenkins.
244.169 -> So this is most relaxed content security policy.
250.59 -> And then after you..
253.29 -> save those changes just restart your Jenkins server.
259.549 -> Ok? and then lets try to refresh our page.
276.419 -> See you are able to see the logs now..
278.96 -> And this will stay here even if you restart the Jenkins.
282.81 -> And this is kind of permanent fix for you now.
287.21 -> In case it does not works even after restarting Jenkins.
290.919 -> You better clear the cache of browser, It should work for you.
295.129 -> So ya.. that's it for the video friends, Thank you for watching and don't forget to subscribe.
301.16 -> see you in the next video..
302.29 -> Bbye..

Source: https://www.youtube.com/watch?v=Cw3RMYGOldA