Automatically deploy Web applications developed in Java using Jenkins [Tomcat application]

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 the Spring Boot application to the JVM server, refer to Spring Boot App.

Job flow of Jenkins [^ 1]

  1. Check out the source code
  2. Build with Maven and output war file
  3. Use Tomcat Manager to transfer the war file to the Tomcat server and deploy it

Check out the source code

Select Git from ** Manage source code **, and check out the Github repository prepared in the preparation section. [^ 2] For branch, specify * / master.

Run build with Maven and output war file

Select ** Run Shell ** and run it with the ./mvnw command.

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 WebSpringMvc
./mvnw clean package

When you run Maven, web-spring-mvc.war will be generated in the / WebSpringMvc / target folder.

Use Tomcat Manager to transfer the war file to the Tomcat server for deployment

Select ** Run Shell ** and run Tomcat's manager command in curl to deploy the war file.

# path=/You can specify the context path of the application with the app parameter
curl --upload-file WebSpringMvc/target/web-spring-mvc.war "http://admin:[email protected]:8080/manager/text/deploy?path=/app&update=true"

If the Jenkins job execution is successful, you can check the application execution from the following URL. http://192.168.33.30:8080/app/greeting

Build setting screen

image.png

reference

Configuring Manager Application Access

[^ 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 / WebSpringMvc.

Recommended Posts

Automatically deploy Web applications developed in Java using Jenkins [Tomcat application]
Automatically deploy a Web application developed in Java using Jenkins [Preparation]
ERRORCODE = -4471 occurs in Java application using Db2.
Role of JSP in Web application [Java]
Deploy an image consisting of Tomcat, Java and MySQL using Ansible and Jenkins
Automatically deploy applications by linking Github and Jenkins.
Deploy Java application developed in IntelliJ IDEA environment to Alibaba Cloud ECS instance
Security in web applications
Remote debugging of Java applications in Azure Web Apps
Web application development environment construction in Java (for inexperienced people)
How to deploy Java application to Alibaba Cloud EDAS in Eclipse
Try using RocksDB in Java
[Probably the easiest] WEB application development with Apache Tomcat + Java Servlet
Run Java application in Azure Batch
Encrypt using RSA cryptography in Java
HTTPS connection using tls1.2 in Java 6
I tried using JWT in Java
Java beginner tried to make a simple web application using Spring Boot
Deploy the WEB application by Spring Boot to Tomcat server as WAR
[Java] Deploy a web application created with Eclipse + Maven + Ontology on Heroku
I tried to make a talk application in Java using AI "A3RT"
The story that the Servlet could not be loaded in the Java Web application
[AWS] How to automatically deploy a Web application created with Rails 6 to ECR / ECS using CircleCI ① Preparation [Container deployment]