Przeglądaj źródła

新建定时任务

mac 2 lat temu
rodzic
commit
71821f1cd6
3 zmienionych plików z 281 dodań i 0 usunięć
  1. 95 0
      .drone.yml
  2. 96 0
      drone/.drone-test.yml
  3. 90 0
      kxs-quartz/pom.xml

+ 95 - 0
.drone.yml

@@ -93,6 +93,101 @@ trigger:
       - pull_request
       - push
 
+---
+kind: pipeline
+type: docker
+name: kxs-quartz-test
+
+volumes: # 声明数据卷
+  - name: mvn_repo # 数据卷名称
+    # Host Volume, 挂载到宿主机上的卷轴
+    host:
+      # 宿主机的绝对路径
+      path: /home/ABServer/cache/mvn_repo
+  - name: mvn_config
+    host:
+      path: /home/ABServer/config/mvn/
+  - name: targetDir
+    host:
+      path: /kxs-quartz
+
+clone:
+  disable: false # 启用代码拉取
+
+steps:
+  - name: build-project
+    image: maven:3.9.4-amazoncorretto-17
+    pull: if-not-exists
+    depends_on: [clone] # 依赖的步骤
+    volumes: # 挂载数据卷
+      - name: mvn_repo # 数据卷名称
+        path: /usr/share/maven/repo # 容器内目录 绝对路径
+      - name: targetDir
+        path: /drone/src/dist/
+      - name: mvn_config
+        path: /usr/share/maven/conf/
+    commands: # 执行命令
+      - mvn clean package -Dmaven.test.skip=true -P test
+      - cp /drone/src/kxs-quartz/target/*.jar /drone/src/dist/ && cp -r /drone/src/kxs-quartz/target/lib /drone/src/dist/ && cp -r /drone/src/kxs-quartz/target/config /drone/src/dist/ # 复制文件
+    when:
+      status:
+        - success # 当前步骤成功时执行
+  - name: scp-project
+    image: appleboy/drone-scp
+    pull: if-not-exists
+    depends_on: [build-project] # 依赖的步骤
+    volumes: # 挂载数据卷
+      - name: targetDir # 数据卷名称
+        path: /kxs-quartz # 容器内目录 绝对路径
+    settings:
+      host:
+        from_secret: host
+      username:
+        from_secret: username
+      password:
+        from_secret: userpwd
+      port: 22
+      command_timeout: 2m
+      target: /home/ABServer/deploy-ready/
+      source:
+        - echo ====开始拷贝=======
+        - /kxs-quartz/*.jar
+        - /kxs-quartz/lib
+        - /kxs-quartz/config
+        - echo ====结束拷贝=======
+      when:
+        status:
+          - success # 当前步骤成功时执行
+
+  - name: deploy-project
+    image: appleboy/drone-ssh
+    pull: if-not-exists
+    depends_on: [scp-project] # 依赖的步骤
+    settings:
+      host:
+        from_secret: host
+      username:
+        from_secret: username
+      password:
+        from_secret: userpwd
+      port: 22
+      command_timeout: 2m
+      script:
+        - echo ====开始部署=======
+        - cd /home/ABServer/
+        - cp -r /home/ABServer/deploy-ready/kxs-quartz /home/ABServer/webroot/
+        - docker restart kxs-quartz
+        # - docker restart nodeServer1
+        - echo ====部署成功=======
+
+trigger:
+  branch:
+    include:
+      - test-quartz
+  event:
+    include:
+      - pull_request
+      - push
 
 ---
 kind: pipeline

+ 96 - 0
drone/.drone-test.yml

@@ -93,6 +93,102 @@ trigger:
       - pull_request
       - push
 
+---
+kind: pipeline
+type: docker
+name: kxs-quartz-test
+
+volumes: # 声明数据卷
+  - name: mvn_repo # 数据卷名称
+    # Host Volume, 挂载到宿主机上的卷轴
+    host:
+      # 宿主机的绝对路径
+      path: /home/ABServer/cache/mvn_repo
+  - name: mvn_config
+    host:
+      path: /home/ABServer/config/mvn/
+  - name: targetDir
+    host:
+      path: /kxs-quartz
+
+clone:
+  disable: false # 启用代码拉取
+
+steps:
+  - name: build-project
+    image: maven:3.9.4-amazoncorretto-17
+    pull: if-not-exists
+    depends_on: [clone] # 依赖的步骤
+    volumes: # 挂载数据卷
+      - name: mvn_repo # 数据卷名称
+        path: /usr/share/maven/repo # 容器内目录 绝对路径
+      - name: targetDir
+        path: /drone/src/dist/
+      - name: mvn_config
+        path: /usr/share/maven/conf/
+    commands: # 执行命令
+      - mvn clean package -Dmaven.test.skip=true -P test
+      - cp /drone/src/kxs-quartz/target/*.jar /drone/src/dist/ && cp -r /drone/src/kxs-quartz/target/lib /drone/src/dist/ && cp -r /drone/src/kxs-quartz/target/config /drone/src/dist/ # 复制文件
+    when:
+      status:
+        - success # 当前步骤成功时执行
+  - name: scp-project
+    image: appleboy/drone-scp
+    pull: if-not-exists
+    depends_on: [build-project] # 依赖的步骤
+    volumes: # 挂载数据卷
+      - name: targetDir # 数据卷名称
+        path: /kxs-quartz # 容器内目录 绝对路径
+    settings:
+      host:
+        from_secret: host
+      username:
+        from_secret: username
+      password:
+        from_secret: userpwd
+      port: 22
+      command_timeout: 2m
+      target: /home/ABServer/deploy-ready/
+      source:
+        - echo ====开始拷贝=======
+        - /kxs-quartz/*.jar
+        - /kxs-quartz/lib
+        - /kxs-quartz/config
+        - echo ====结束拷贝=======
+      when:
+        status:
+          - success # 当前步骤成功时执行
+
+  - name: deploy-project
+    image: appleboy/drone-ssh
+    pull: if-not-exists
+    depends_on: [scp-project] # 依赖的步骤
+    settings:
+      host:
+        from_secret: host
+      username:
+        from_secret: username
+      password:
+        from_secret: userpwd
+      port: 22
+      command_timeout: 2m
+      script:
+        - echo ====开始部署=======
+        - cd /home/ABServer/
+        - cp -r /home/ABServer/deploy-ready/kxs-quartz /home/ABServer/webroot/
+        - docker restart kxs-quartz
+        # - docker restart nodeServer1
+        - echo ====部署成功=======
+
+trigger:
+  branch:
+    include:
+      - test-quartz
+  event:
+    include:
+      - pull_request
+      - push
+
 ---
 kind: pipeline
 type: docker

+ 90 - 0
kxs-quartz/pom.xml

@@ -67,10 +67,100 @@
     </dependencies>
 
     <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+            <!--打包java路径下的静态文件-->
+            <resource>
+                <directory>src/main/java</directory>
+                <filtering>false</filtering>
+                <includes>
+                    <include>**/*.xml</include>
+                </includes>
+            </resource>
+        </resources>
         <plugins>
+            <!--该插件的作用是打包spring-boot的jar包-->
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <!--不排除的话,systemScope的依赖包会自动被此插件打包进xxx.jar\BOOT-INF\lib,和外部依赖产生冲突 -->
+                    <includeSystemScope>false</includeSystemScope>
+                    <skip>false</skip>
+                    <!--分离Jar包-->
+                    <layout>ZIP</layout>
+                    <includes>
+                        <include>
+                            <groupId>nothing</groupId>
+                            <artifactId>nothing</artifactId>
+                        </include>
+                    </includes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- 该插件的作用是复制依赖的jar包到指定的文件夹里 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-dependencies</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/lib/</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- 该插件的作用是复制指定的文件 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <!-- 复制配置文件 -->
+                    <execution>
+                        <id>copy-resources</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <configuration>
+                            <resources>
+                                <!--复制资源文件到外部,注意这里先不做filtering处理,防止某些静态文件损坏-->
+                                <resource>
+                                    <filtering>false</filtering>
+                                    <directory>src/main/resources</directory>
+                                    <includes>
+                                        <include>**/*</include>
+                                    </includes>
+                                </resource>
+                                <!--仅针对配置文件filtering处理(占位符@@等)-->
+                                <resource>
+                                    <directory>src/main/resources</directory>
+                                    <filtering>true</filtering>
+                                    <includes>
+                                        <include>*.xml</include>
+                                        <include>*.yml</include>
+                                        <include>*.properties</include>
+                                    </includes>
+                                </resource>
+                            </resources>
+                            <outputDirectory>${project.build.directory}/config</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
             </plugin>
         </plugins>
     </build>