• java+maven+testng+allure+git搭建持续集成报告配置


    一、框架:

    Java+testng+maven+Jenkins+allure+git

    二、邮件配置

    1、系统管理-插件
    插件管理搜索Email Extension Plugin以及Allure Jenkins Plugin(傻瓜方式安装就行)在Allure Jenkins Plugin插入图片描述
    在这里插入图片描述
    2、系统管理-系统配置
    a、邮件配置
    在这里插入图片描述
    密码在腾讯企业邮箱中的微信绑定-安全登录-客户端专用密码
    SMTP端口看你的用的是哪个邮箱,找相应的端口就好了
    在这里插入图片描述
    b、Jenkins Location配置

    在这里插入图片描述
    c、Default Recipients配置
    在这里插入图片描述
    这配置主要就是接收邮件的人,多个邮件以英文逗号分隔
    d、Default Subject

    $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!
    
    • 1

    e、Default Content

    $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
    
    Check console output at $BUILD_URL to view the results.
    
    • 1
    • 2
    • 3

    f、项目中Editable Email Notification配置
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    Editable Email Notification解释:
    1、Project Recipient List–变量来自系统配置中 c、Default Recipients配置

    $DEFAULT_RECIPIENTS
    
    • 1

    2、Project Reply-To List

    $DEFAULT_REPLYTO
    
    • 1

    3、Content Type选择HTML
    4、Default Subject–汉子部分可根据自身需求定制

    $PROJECT_NAME -接口测试 test- Build #$BUILD_NUMBER - $BUILD_STATUS!
    
    • 1

    5、Default Content

    <!DOCTYPE html>    
    <html>    
    <head>    
    <meta charset="UTF-8">    
    <title>${ENV, var="JOB_NAME"}-第${BUILD_NUMBER}次构建日志</title>    
    </head>    
        
    <body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4"    
        offset="0">    
        <table width="95%" cellpadding="0" cellspacing="0"  style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">    
            <tr>    
                本邮件由系统自动发出,无需回复!<br/>            
                各位同事,大家好,以下为${PROJECT_NAME }项目构建信息</br> 
                <td><font color="#CC0000">构建结果 - ${BUILD_STATUS}</font></td>   
            </tr>    
            <tr>    
                <td><br />    
                <b><font color="#0B610B">构建信息</font></b>    
                <hr size="2" width="100%" align="center" /></td>    
            </tr>    
            <tr>    
                <td>    
                    <ul>    
                        <li>执行人员:${CAUSE}</li>
                        <li>项目名称 : ${PROJECT_NAME}</li>    
                        <li>构建编号 : 第${BUILD_NUMBER}次构建</li>    
                        <li>触发原因: ${CAUSE}</li>    
                        <li>构建状态: ${BUILD_STATUS}</li>    
                        <li>构建日志: <a href="${BUILD_URL}console">${BUILD_URL}console</a></li>    
                        <li>构建  Url : <a href="${BUILD_URL}">${BUILD_URL}</a></li>    
                        <li>工作目录 : <a href="${PROJECT_URL}ws">${PROJECT_URL}ws</a></li>    
                        <li>项目  Url : <a href="${PROJECT_URL}">${PROJECT_URL}</a></li>  
                        <li>通过数量:<font color="#00FF00">${TEST_COUNTS, var="pass"}</font></li>
                        <li>失败数量:<font color="#FF0000">${TEST_COUNTS, var="fail"}</font></li>
                        <li>测试结果:****具体内容,请查看测试报告****</li>
                        <li>测试报告:<a href="${PROJECT_URL}/${BUILD_NUMBER}/allure">${PROJECT_URL}/${BUILD_NUMBER}/allure</a></td>
      
                    </ul>    
    
    <h4><font color="#0B610B">失败用例</font></h4>
    <hr size="2" width="100%" />
    $FAILED_TESTS<br/>
    
    <h4><font color="#0B610B">最近提交(#$GIT_REVISION)
    <hr size="2" width="100%" />
    <ul>
    ${CHANGES_SINCE_LAST_SUCCESS, reverse=true, format="%c", changesFormat="
  • %d [%a] %m</li>"} </ul> 详细提交: <a href="${PROJECT_URL}changes">${PROJECT_URL}changes</a><br/> </td> </tr> </table> </body> </html>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
  • 三、allure配置

    1、系统配置-Allure Report
    在这里插入图片描述
    key和value自定义即可
    2、项目中构建后操作
    在这里插入图片描述
    在好多博客上看到说这是配置的相对路径,配置的相对路径之后也是不出来,后来改成allure-results坐在包下就好了,我的allure-results路径是以下截图,这个路径在Jenkins的工作空间就能找到。
    在这里插入图片描述

    三、git配置

    在这里插入图片描述

    四、pom配置

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>org.example</groupId>
        <artifactId>sby_qa_autotest</artifactId>
        <version>1.0-SNAPSHOT</version>
    
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.3.4.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
    
        <build>
            <plugins>
                <plugin>
    
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>8</source>
                        <target>8</target>
                    </configuration>
                </plugin>
                <!-- 测试用 res/testngApp.xml ; 正式用:res/${xmlFileName} -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.19.1</version>
                    <configuration>
                        <suiteXmlFiles>
                            <!--suppress UnresolvedMavenProperty -->
                        <suiteXmlFile>res/${xmlFileName}</suiteXmlFile>
    <!--                        <suiteXmlFile>res/${testngapi.xml}</suiteXmlFile>-->
    
                        </suiteXmlFiles>
                        <!--设置参数命令行 -->
                        <argLine>
                            <!-- UTF-8编码 -->
                            -Dfile.encoding=UTF-8
                            <!-- 配置拦截器 -->
                            -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                        </argLine>
                        <testFailureIgnore>true</testFailureIgnore>
                        <properties>
                            <property>
                                <name>listener</name>
                                <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
                                <name>usedefaultlisteners</name>
                                <value>false</value>
                            </property>
    
                            <properties>
                                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                                <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
                                <aspectj.version>1.8.13</aspectj.version>
                            </properties>
    
                        </properties>
    
                        <systemProperties>
                            <property>
                                <!-- 配置 allure 结果存储路径  -->
                                <name>allure.results.directory</name>
                                <value>${project.build.directory}/allure-results</value>
                            </property>
                        </systemProperties>
                        <workingDirectory>target/</workingDirectory>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.aspectj</groupId>
                            <artifactId>aspectjweaver</artifactId>
                            <version>${aspectj.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
            <finalName>aototest</finalName>
        </build>
    
        <dependencies>
    
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </dependency>
            <!-- aspectjweaver maven坐标 -->
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>1.9.6</version>
                <scope>runtime</scope>
            </dependency>
    
            <!-- surefire-testng -->
            <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-testng</artifactId>
            <version>2.19.1</version>
        </dependency>
    
        <!-- poi to excel -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.10.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>xml-apis</artifactId>
                    <groupId>xml-apis</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    
        <!-- httpclient -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.5</version>
        </dependency>
    
            <dependency>
                <groupId>commons-httpclient</groupId>
                <artifactId>commons-httpclient</artifactId>
                <version>3.1</version>
            </dependency>
    
        <!-- testng配置 -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.9.9</version>
        </dependency>
            <dependency>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-testng</artifactId>
                <version>2.13.6</version>
            </dependency>
    
         <!-- JSONObject -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>1.2.47</version>
            </dependency>
    
            <!-- json -->
            <dependency>
                <groupId>net.sf.json-lib</groupId>
                <artifactId>json-lib</artifactId>
                <version>2.4</version>
                <classifier>jdk15</classifier>
            </dependency>
    
            <!-- log4j -->
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>
    
            <!-- dbcp -->
            <dependency>
                <groupId>commons-dbcp</groupId>
                <artifactId>commons-dbcp</artifactId>
                <version>1.4</version>
            </dependency>
    
            <!--数据库驱动-->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.38</version>
                <scope>test</scope>
            </dependency>
    
            <!-- md5 -->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.3.2</version>
            </dependency>
    
            <!-- Servlet依赖 -->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.5</version>
            </dependency>
    
            <dependency>
                <groupId>xerces</groupId>
                <artifactId>xercesImpl</artifactId>
                <version>2.9.1</version>
            </dependency>
    
            <!-- reportng替代testng报告 -->
            <dependency>
                <groupId>org.uncommons</groupId>
                <artifactId>reportng</artifactId>
                <version>1.1.4</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.testng</groupId>
                        <artifactId>testng</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    
            <dependency>
                <groupId>com.google.inject</groupId>
                <artifactId>guice</artifactId>
                <version>4.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>commons-dbutils</groupId>
                <artifactId>commons-dbutils</artifactId>
                <version>1.6</version>
                <scope>compile</scope>
            </dependency>
    
        </dependencies>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
    
    </project>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236

    完后后的样子
    在这里插入图片描述

    文章中可能有的地方写的不大详细,或者写的写的不对的地方,大家有问题留言就好,看到之后我会给大家解答和讨论

  • 相关阅读:
    互联网热门词汇:O2O、C2C、B2B、B2C 的区别在哪里?
    Llama2-Chinese项目:6-模型评测
    SpringBoot 开启定时任务
    如何在 libevent 中读取超过 4096 字节的数据
    Java+JSP+MySQL基于SSM的在线投票系统-计算机毕业设计
    自采集壁纸网页源码
    HC32F120开发之IAP
    C语言实现扫雷小游戏
    MySql 数据库【Union、Limit】
    NTSC和PAL视频格式的区别
  • 原文地址:https://blog.csdn.net/weixin_38337769/article/details/126795048