How to deploy java application (war) to EC2 using jenkins?

I am creating a development environment for a java project. And my team decided to use Jenkins for CI and AWS EC2 (linux) for server.

I was able to create a war file by jenkins work. But I can't find a way to copy the war file in EC2 and restart the tomcat server on EC2.

I figured it out with "jenkins ec2 deploy" but with error.

somebody help me!

+3


source to share


2 answers


Step 1. Install Jenkins plugin

Open your favorite browser and go to Jenkins. Log in and select "Manage Jenkins" and then "Manage Plugin". Select the "Available" tab, find the "Deploy to Container" plugin and install it.

Step 2. Editing tomcat-users.xml

To make Tomcat accept remote deployments, you need to add a user with a role manager - script. To do this, edit the .. / conf / tomcat -users.xml file and add the following line:

<user username="deployer" password="deployer" roles="manager-script" />

      

Step 3. Edit Jenkins' job



Go back to Jenkins, go to your work and select Customize. Then scroll down to the bottom of the page under Post-Build Actions. Select the "Deploy War / Ear to Container" option from the "Add Post Build" dropdown menu. Fill in the new fields.

Step 4. Run the Job project and check the final results

Schedule a build for your work in Jenkins. If you check the log file, you will see one or more lines towards the end, indicating that the war file has been expanded.

If you check the log files in Tomcat (catalina.out), you will also see that your application has been successfully deployed.

Finally, if you point your browser to the URL and context you specified in the job configuration in Jenkins (for example, http: // your-server: 8080 / mywebapp ), you should be able to open the newly deployed application.

Credits to Jdev.it More information can be found here

0


source


With EC2 (or any other deployment practice), first determine that your production servers will be volatile or immutable.

[Mutable] The servers will run forever and you are performing ongoing updates as described in the blog (elizabetht) mentioned above for the Java War, or in many other language / platform variations.



[Immutable] Servers are re-created (or updated) using an automation mechanism such as scripting or using configuration. mgmt tools like the Puppet / Chef / Ansible launcher or vendor like AWS Userdata / Docker dockerfile / Vagrant vagrantfile or using many other build tools.

In general, databases or queues should be Mutable categories, and all other compute nodes are better off being immutable. The benefits of the immutable category are many, including lightweight HA, disaster recovery, and the ability to deploy Blue / Green and more.

-3


source







All Articles