jenkins+git+webdriver+maven+docker+testNG

git服务器:源码安装(忽略apt-get的低版本)---参考:https://blog.csdn.net/csdnkongfanhu/article/details/84585519
1.git官网下载源码(当前使用版本为2.11.0)
2.压缩包解压,命令为:tar -zxvf git.tar.gz
3.安装编译源码所需依赖,命令为:yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
4.安装依赖时,yum自动安装了Git,需要卸载旧版本Git,命令为:yum remove git
5.进入解压后的文件夹,命令cd git,然后执行编译,命令为 make prefix=/usr/local/git all
6.安装Git至/usr/local/git路径,命令为 make prefix=/usr/local/git install
7.打开环境变量配置文件,命令 vim /etc/profile,在底部加上Git相关配置信息:export PATH=$PATH:/usr/local/git/bin
8.source /etc/profile,配置立即生效!
9.输入命令 git --version,查看安装的git版本,校验通过,安装成功

测试环境:jenkins+git+maven+docker

jdk:官网下载rpm安装,自动添加环境变量(当前使用版本为1.8)

docker:yum安装(当前使用版本为1.13.1)---参考:https://www.cnblogs.com/myzony/p/9071210.html
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install docker-ce
sudo systemctl enable docker
sudo systemctl start docker
暂时用不到docker compose

git:如上述,源码安装,版本低有问题(当前使用版本为2.9.5)

maven:官网下载tar.gz后,配置环境变量,版本太低的话,pom.xml插件运行testng会报错(当前使用版本为3.6.3)
export MAVEN_HOME=/usr/local/apache-maven-3.6.3
export PATH=$MAVEN_HOME/bin:$PATH
source /etc/profile

jenkins安装:参看官网安装(当前安装版本为2.235.3)
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install jenkins;
systemctl start/stop/restart/status jenkins

安装插件:Safe Restart Plugin;SSH plugin;HTML Publisher plugin;

全局凭据配置:
1.git配置:

jenkins+git+webdriver+maven+docker+testNG

2.linux用户配置:

jenkins+git+webdriver+maven+docker+testNG

全局工具配置:

jenkins+git+webdriver+maven+docker+testNG

jenkins+git+webdriver+maven+docker+testNG

jenkins+git+webdriver+maven+docker+testNG

jenkins+git+webdriver+maven+docker+testNG

系统配置:

jenkins+git+webdriver+maven+docker+testNG

创建项目:

1.源码管理:

jenkins+git+webdriver+maven+docker+testNG

2.构建触发器

jenkins+git+webdriver+maven+docker+testNG

3.构建环境

jenkins+git+webdriver+maven+docker+testNG

4.构建

jenkins+git+webdriver+maven+docker+testNG

5.构建后操作

jenkins+git+webdriver+maven+docker+testNG

工程概要:
1.转maven工程
2.确保测试文件夹,mark dir as test sources root
3.优化测试报表,使用reportng,idea自动生成testng.xml后,配置监听器
    <listeners>
        <listener class-name="org.uncommons.reportng.HTMLReporter" />
        <listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
    </listeners>
4.确认maven插件版本,否则执行时报错
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M5</version>
        <configuration>
            <suiteXmlFiles>
                <suiteXmlFile>testng.xml</suiteXmlFile>
            </suiteXmlFiles>
        </configuration>
    </plugin>

------------------------------------------------------------------------------

a.执行后,因为jenkins配置原因,导致报表无法显示。需要修改属性
---参考:https://blog.csdn.net/a19891024/article/details/54098972
报错the document's frame is sandboxed and the 'allow-scripts' permission is not set; 
it violates the following Content Security Policy directive: "default-src 'none'"
系统管理->脚本命令行执行命令:
1.System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","sandbox allow-scripts; default-src 'none';script-src 'unsafe-inline' http://code.jquery.com/jquery-2.1.0.min.js; img-src dohko.hpeswlab.net 'self' data: ; style-src 'unsafe-inline' 'self';");
2.System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

 

------------------参看工程:https://github.com/crusjc/SoftTest.git

生成报告:

jenkins+git+webdriver+maven+docker+testNG

------------------忽略使用root用户操作部分:)