简体   繁体   中英

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. 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.

To achieve this in Jenkins what is the best solutions.

  1. Is it possible to have a single Jenkins job and achieve the above scenario? (like in post-build steps to run the generated jar as an application using the command and run the integration test on it)

  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.

Please suggest the best possible solution.

Thanks in advance.

Bala.

This should help (if you're using maven to build the project). The general idea is to use your build tool than can manage the whole process itself within one Jenkins job.

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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