简体   繁体   English

带有集成测试的 Spring Boot 应用程序的 Jenkins 作业

[英]Jenkins jobs for spring boot application with Integration testing

The following is my scenario.以下是我的场景。

I have my application which is built on Spring boot with embedded tomcat server.我有我的应用程序,它构建在带有嵌入式 tomcat 服务器的 Spring Boot 上。 In my application, I have unit tests as well as integration tests.在我的应用程序中,我有单元测试和集成测试。

First I want to build my application as a maven package (jar) which will cover all the unit tests and then the next step is to run the jar file as spring boot application ((java -jar myapplication.jar) which will start the tomcat server. As a final step, I want to run my integration tests on top of the running spring boot application.首先,我想将我的应用程序构建为一个 maven 包(jar),它将涵盖所有单元测试,然后下一步是将 jar 文件作为 spring 启动应用程序((java -jar myapplication.jar)运行,它将启动 tomcat服务器。作为最后一步,我想在正在运行的 Spring Boot 应用程序之上运行我的集成测试。

To achieve this in Jenkins what is the best solutions.要在 Jenkins 中实现这一点,最好的解决方案是什么。

  1. Is it possible to have a single Jenkins job and achieve the above scenario?是否有可能有一个 Jenkins 工作并实现上述场景? (like in post-build steps to run the generated jar as an application using the command and run the integration test on it) (就像在构建后步骤中使用命令将生成的 jar 作为应用程序运行并在其上运行集成测试)

  2. Else will create 3 jobs in Jenkins ( one for maven package, the second one for deploying the generated jar file and run the application and third one is for running the integration tests on top of the running application.否则将在 Jenkins 中创建 3 个作业(一个用于 maven 包,第二个用于部署生成的 jar 文件并运行应用程序,第三个用于在正在运行的应用程序之上运行集成测试。

Please suggest the best possible solution.请建议最好的解决方案。

Thanks in advance.提前致谢。

Bala.巴拉。

This should help (if you're using maven to build the project).这应该会有所帮助(如果您使用 maven 来构建项目)。 The general idea is to use your build tool than can manage the whole process itself within one Jenkins job.一般的想法是使用您的构建工具,而不是可以在一个 Jenkins 工作中管理整个过程。

<plugin>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-maven-plugin</artifactId>
   <executions>
      <execution>
         <id>pre-integration-test</id>
         <goals>
            <goal>start</goal>
         </goals>
      </execution>
      <execution>
         <id>post-integration-test</id>
         <goals>
            <goal>stop</goal>
         </goals>
      </execution>
   </executions>
</plugin>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM