美文网首页
代码测试覆盖率(一)

代码测试覆盖率(一)

作者: 天草二十六_简村人 | 来源:发表于2022-08-17 17:30 被阅读0次

一、安装依赖

1.1、diff-cover

制作私有的docker镜像,在K8S的pod中启动容器diff-cover。

  • 拉取外部镜像

我们没有自己去制作docker镜像,而是直接从dockerhub寻找现有的镜像。地址是:https://hub.docker.com/r/twistersfury/diff-coverhttps://github.com/Bachmann1234/diff_cover

> docker pull twistersfury/diff-cover
> docker images | grep "diff-cover"
twistersfury/diff-cover                                           latest                 d179e002da45   7 months ago    943MB
  • docker tag
> sudo docker tag d179e002da45 harbor.xx.cloud/library/diff-cover:20220817093510

> docker images | grep "diff-cover"
twistersfury/diff-cover                                           latest                 d179e002da45   7 months ago    943MB
harbor.xx.cloud/library/diff-cover                                20220817093510         d179e002da45   7 months ago    943MB
  • docker push
> docker login harbor.xx.cloud
> sudo docker push harbor.xx.cloud/library/diff-cover:20220817093510
The push refers to repository [harbor.xx.cloud/library/diff-cover]
e0803a8edddd: Pushed 
fc95c76f747d: Pushed 
0583228d80f1: Pushed 
0184d2abe6b0: Pushed 
db8d0fe6cf95: Pushed 
00901a4c6fc7: Pushed 
7e7decd61f68: Pushed 
aedcb370b058: Pushed 
c3a0d593ed24: Pushed 
26a504e63be4: Pushed 
8bf42db0de72: Pushed 
31892cc314cb: Pushed 
11936051f93b: Pushed 
20220817093510: digest: sha256:8644123f7d9c523b318343d6285709d43ca94f1948db56334de0ea270800fa3a size: 3053
harbor.png
推送成功.png

1.2、ant

类同上一步的操作,这里就不赘述。https://hub.docker.com/r/webratio/ant

> docker pull webratio/ant
  • 环境变量

vi ~/.bashrc

# restart
source /etc/profile

vi /etc/profile

# ant
export ANT_HOME=/opt/apache-ant-1.10.12
export PATH=:$ANT_HOME/bin:$PATH
  • 下载并解压


    image.png
531754e9d857:/opt# wget https://dlcdn.apache.org//ant/binaries/apache-ant-1.10.12-bin.tar.gz
531754e9d857:/opt# tar -zxvf apache-ant-1.10.12-bin.tar.gz
531754e9d857:/opt# ls
apache-ant-1.10.12             apache-ant-1.10.12-bin.tar.gz

二、安装jenkins plugin

  • 安装Permissive Script Security Plugin插件


    image.png
  • 添加签名
staticMethod java.lang.System setProperty java.lang.String java.lang.String
image.png

注意,这里都是不可编辑的文本框,无法手动输入。必须在jenkins job运行的时候,console控制台输出的日志,有链接跳转进来。

Scripts not permitted to use staticMethod java.lang.System setProperty java.lang.String java.lang.String. Administrators can decide whether to approve or reject this signature.

image.png

这个时候才会提示,让你approve。


image.png
  • -Dpermissive-script-security.enabled=true
  • -DsessionTimeout=480(单位:分钟)

相关文章

网友评论

      本文标题:代码测试覆盖率(一)

      本文链接:https://www.haomeiwen.com/subject/gvdjgrtx.html