Solution to the problem that the test report cannot be displayed normally or is displayed blank after Jenkins is configured (problem collection)

Phenomenon 1: Interface style disorder

  • After opening the report, the interface style is messed up, as follows:
    Insert image description here

Cause Analysis

  • The reason for this phenomenon lies in Jenkinsthe configuration CSP(Content Security Policy);
  • This is Jenkinsa security policy that is set to a very strict permission set by default to prevent Jenkinsusers workspace、/userContent、archived artifactsfrom being attacked by malicious HTML/JSfiles;
  • By default, this permission set is set to:
sandbox; default-src 'none'; img-src 'self'; style-src 'self';
  • By default, only loading is allowed:
Jenkins服务器上托管的CSS文件
Jenkins服务器上托管的图片文件
  • At this time the following content will be prohibited:
JavaScript
plugins (object/embed)
HTML中的内联样式表(Inline style sheets),以及引用的外站CSS文件
HTML中的内联图片(Inline image definitions),以及外站引用的图片文件
frames
web fonts
XHR/AJAX
etc.

temporary strategy

  • Enter Manage Jenkins->Script console, enter the following command and execute it;
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
  • as follows:
    Insert image description here
  • After entering the command and running it, if it is empty, it means the configuration is complete, as follows:
    Insert image description here
  • Build again. At this time, the interface style displays OK, as follows:
    Insert image description here
  • The above operation is effective for reports generated by previous builds HTML, and is only temporarily effective. When restarted Jenkins, Content Security Policyit will be restored to the default value, and HTMLthe style will no longer be displayed.

permanent strategy

  • Install Groovythe plug-in as follows:
    Insert image description here
  • Go to Project-Configuration- Execute Groovy script:
    Insert image description here
  • Enter the following content and save:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

Insert image description here

Phenomenon 2: The report path does not exist

  • For example, when building, it is prompted that the report path does not exist and needs to be created manually. The error message is as follows:
Jenkins - HTML Publisher Plugin build fails with report directory doesnot exist

Cause Analysis

  • Either the report directory you set does not exist in the project directory of the remote warehouse;
  • Either the report directory you set is inconsistent with the report path stored in the warehouse.

solution strategy

  • Set the directory where reports are stored on Jenkins. The following is the directory under the project root directory reports:
    Insert image description here
  • Then confirm whether there is the same directory under the directory of the project in the warehouse:
    Insert image description here
  • As above, there is report in my warehouse, so the two need to be consistent, either yes reportor both reports;
  • Finally, confirm jenkinswhether the project directory in the container is successfully downloaded or synchronized. You can enter jenkinsthe container to view it with the following command:
sudo docker exec -it jenkins bash
 ls /var/jenkins_home/workspace/test_autoui -ls
# /var/jenkins_home/workspace/:这是jenkins容器上项目的工作空间
# test_autoui:这是我的项目名称,改为自己的即可

Insert image description here

  • You can see from the above that there is reporta directory and view the reports inside:
    Insert image description here
  • Only by ensuring that the above points are consistent can the report be displayed normally, because the console information has already given a prompt during the build. It is copied from a certain directory to a zero-one directory:
    Insert image description here

Phenomenon 3: Docker and operating system versions do not match

  • The above two phenomena have been solved, but the report is still not displayed, and the data on the report page is directly displayed blank;

Cause Analysis

  • View the error message output on the console during build:
    Insert image description here
  • That is, the error message is:
lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by docker)
  • This is because the docker version and the operating system version do not match. My environment is:
docker:最新版本
Ubuntu:22.04
  • After consulting the magnetic information, it is possible Ubuntu:22.04to use it if necessary due to the problem Ubuntu18.04、Ubuntu20.04.

solution strategy

  • Reinstall the system, such as using Ubuntu18.04、Ubuntu20.04.

Guess you like

Origin blog.csdn.net/NoamaNelson/article/details/132081388