In order to practice CI / CD, I set up Jenkins to generate Artifacts and deploy it to the application server.
The source code and server construction are described in this Preparation. If you want to automatically deploy to Tomacat server, refer to Tomcat application.
Select Git from ** Manage source code **, and check out the Github repository prepared in the preparation section. [^ 2] For branch, specify * / master.
Select ** Run Shell ** and run it with the
The build uses maven, but it runs in the Maven Wrapper included in the repository instead of the Mave task. Since there are two projects in the repository, I move the current directory to WebSpringBoot before executing it.
cd WebSpringBoot ./mvnw clean package
When you run Maven, web-spring-boot.jar will be generated in / WebSpringBoot / target.
Select ** Run Shell **, SSH into the JVM server and place the generated Artifacts: web-spring-boot.jar. Also, make the transferred jar file full access (rwx) for the following reasons.
--Allow overwriting of files for continuous deployment. --Since it self-starts from the service of the JVM server [^ 3], it allows the execution of the file.
#Transfer the jar file from Jankins to the JVM server with SCP command scp -i ~/.ssh/id_rsa WebSpringBoot/target/web-spring-boot.jar [email protected]:/var/jvm #Grant execute permission ssh -i ~/.ssh/id_rsa [email protected] sudo chmod 700 /var/jvm/web-spring-boot.jar
Select ** Run Shell ** to SSH into the JVM server and restart the application service.
ssh -i ~/.ssh/id_rsa [email protected] sudo systemctl restart app
If the Jenkins job execution is successful, you can check the application execution from the following URL. http://192.168.33.20:8080/
Installing Spring Boot Applications(from Spring Boot Reference) Spring Boot Reference Guide
[^ 1]: This time, I wanted to build and deploy by command execution, so I used the ** Shell execution ** task.
[^ 2]: This repository contains two Maven projects, ** WebSpringMvc ** for war and ** WebSpringBoot ** for jar. This time, we will use / WebSpringBoot.
[^ 3]: To make the jar executable, set the executable setting of spring-boot-maven-plugin to true