From 3ea0a617c945a224a89ae0212fa108c5c96b8793 Mon Sep 17 00:00:00 2001
From: wangzilun <964606955@qq.com>
Date: Wed, 15 Dec 2021 17:28:06 +0800
Subject: [PATCH] 引入maven测试

---
 Jenkinsfile                                            |   11 +++++
 .gitignore                                             |    5 ++
 src/pom.xml                                            |   39 +++++++++++++++++++
 src/test/java/com/hbbohua/gitStudy/HelloWorldTest.java |   10 +++++
 4 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index ef67264..ef6b348 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,4 +11,7 @@
 # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
 hs_err_pid*
 /.idea/
-gitflow-installer.sh
\ No newline at end of file
+gitflow-installer.sh
+target/
+**/target/
+*.iml
\ No newline at end of file
diff --git a/Jenkinsfile b/Jenkinsfile
index 4adbfa1..c925415 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -10,6 +10,7 @@
         }
     options {
         //给日志加上时间错, 需安装 Timestamper 插件
+        //mvn test surefire-report:report
         timestamps()
         ansiColor('xterm')
         //丢弃旧的构建前两个为发布包保留天数(比此早的发布包将被删除,但构建的日志、操作历史、报告等将被保留)和构建个数
@@ -29,7 +30,15 @@
 
             }
         }
-        stage('test') {
+        stage('testMaven') {
+            steps {
+
+                sh 'mvn clean test -U'
+                junit allowEmptyResults: true, keepLongStdio: true, skipPublishingChecks: true, testResults: 'target/surefire-reports/*.xml'
+
+            }
+        }
+        stage('testFunction') {
             steps {
 
                 sh '''
diff --git a/src/pom.xml b/src/pom.xml
new file mode 100644
index 0000000..704b7f7
--- /dev/null
+++ b/src/pom.xml
@@ -0,0 +1,39 @@
+<?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>com.hbbohua</groupId>
+    <artifactId>git_study</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>war</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.13</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.13</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <testFailureIgnore>true</testFailureIgnore>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/src/test/java/com/hbbohua/gitStudy/HelloWorldTest.java b/src/test/java/com/hbbohua/gitStudy/HelloWorldTest.java
new file mode 100644
index 0000000..cfbb761
--- /dev/null
+++ b/src/test/java/com/hbbohua/gitStudy/HelloWorldTest.java
@@ -0,0 +1,10 @@
+package com.hbbohua.gitStudy;
+
+import org.junit.Test;
+
+public class HelloWorldTest {
+    @Test
+    public void test1(){
+        System.out.println("hello test....");
+    }
+}

--
Gitblit v1.9.1