<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[build&deployment automation by freestyle]]></title><description><![CDATA[build&deployment automation by freestyle]]></description><link>https://jenkins-freestyle.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 17 Oct 2026 09:11:28 GMT</lastBuildDate><atom:link href="https://jenkins-freestyle.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Setting Up CI/CD with Jenkins, Maven & Tomcat on EC2 (With GitHub Integration)]]></title><description><![CDATA[In this blog post, I’ll walk you through how I set up a simple CI/CD pipeline using Jenkins, Maven, and Tomcat, all hosted on a single EC2 instance. The pipeline automatically pulls code from a GitHub repository, builds it using Maven, and deploys it...]]></description><link>https://jenkins-freestyle.hashnode.dev/setting-up-cicd-with-jenkins-maven-and-tomcat-on-ec2-with-github-integration</link><guid isPermaLink="true">https://jenkins-freestyle.hashnode.dev/setting-up-cicd-with-jenkins-maven-and-tomcat-on-ec2-with-github-integration</guid><dc:creator><![CDATA[akash rawat]]></dc:creator><pubDate>Wed, 11 Jun 2025 21:14:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1749673761222/747989fc-e055-4f4f-b50c-f57c609a540d.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this blog post, I’ll walk you through how I set up a simple CI/CD pipeline using Jenkins, Maven, and Tomcat, all hosted on a single EC2 instance. The pipeline automatically pulls code from a GitHub repository, builds it using Maven, and deploys it to a Tomcat server.</p>
<p><strong>Tools Used</strong></p>
<p>GitHub – To host the application code</p>
<ul>
<li><p>Jenkins – To automate the build and deployment</p>
</li>
<li><p>Maven – For build and packaging</p>
</li>
<li><p>Apache Tomcat – For deploying the Java application</p>
</li>
<li><p>Amazon EC2 – As the hosting server for everything</p>
</li>
</ul>
<p><strong>🔗 Step-by-Step Workflow</strong></p>
<p><strong>1️⃣ Code on GitHub</strong></p>
<p>Your application code lives in a GitHub repository. Whenever you push changes to the repository, it should automatically trigger the Jenkins job.</p>
<p><strong>2️⃣ Jenkins Pulls the Code</strong></p>
<p>Inside Jenkins, configure the job to:</p>
<ul>
<li><p>Use GitHub hook trigger for GITScm polling</p>
</li>
<li><p>Pull code from your GitHub repository whenever there’s a new push</p>
</li>
</ul>
<p>Make sure to set up a webhook in GitHub pointing to your Jenkins server.</p>
<p><strong>3️⃣ Configure Maven Goals in Jenkins</strong></p>
<p>In the Jenkins job:</p>
<ul>
<li>Under Build, specify Maven goals like:</li>
</ul>
<p>clean package- This compiles the code, runs tests, and packages the output (typically a .war file).</p>
<p><strong>4️⃣ Deploy to Tomcat with Plugin</strong></p>
<p>Install the Jenkins plugin:</p>
<p>Deploy to Container</p>
<p>This plugin allows Jenkins to deploy the generated .war file to a Tomcat server.</p>
<p>Configure it in Post-build Actions:</p>
<ul>
<li><p>Specify Tomcat URL</p>
</li>
<li><p>Set Tomcat username/password</p>
</li>
<li><p>Path to .war file</p>
</li>
</ul>
<p><strong>5️⃣ All on Same EC2 Instance</strong></p>
<p>Both Jenkins and Tomcat are installed on the same EC2 instance.</p>
<p><strong>5️⃣ All on Same EC2 Instance</strong></p>
<p>Both Jenkins and Tomcat are installed on the same EC2 instance.</p>
<p><strong>6️⃣ Tomcat Port Change</strong></p>
<p>By default, Jenkins and Tomcat both use port 8080. To avoid port conflict, we changed Tomcat’s port to 9080.</p>
<p>You can do this by editing server.xml in the Tomcat conf directory:</p>
<p>&lt;Connector port="9080" protocol="HTTP/1.1" ... /&gt;</p>
<p><strong>✅ CI/CD in Action</strong></p>
<p>Here’s how it all ties together:</p>
<ul>
<li><p>You push code to GitHub</p>
</li>
<li><p>GitHub sends a webhook trigger to Jenkins</p>
</li>
<li><p>Jenkins pulls the latest code</p>
</li>
<li><p>Jenkins runs Maven to build the app</p>
</li>
<li><p>Jenkins deploys the .war file to Tomcat via post-build action</p>
</li>
<li><p>App is now live on the EC2 instance (via Tomcat on port 9080)</p>
</li>
</ul>
]]></content:encoded></item></channel></rss>