AWS Builder Center

My First Experience with Jenkins: Automating Deployments on AWS EC2

A beginner-friendly overview of setting up a Jenkins CI/CD pipeline from scratch. Read about my hands-on experience provisioning an AWS EC2 instance, configuring security groups, and building a declarative pipeline for a Java application.

My First Experience with Jenkins: Automating Deployments on AWS EC2
As a computer engineering student diving into the world of DevOps, I had read plenty of theory about Continuous Integration and Continuous Deployment (CI/CD). But nothing compares to the breakthrough of building an automated pipeline from scratch. Recently, I set up my first Jenkins pipeline on an AWS EC2 instance to automate a Java application build, specifically targeting the Spring PetClinic project.
Here is a breakdown of my first hands-on experience and the steps I took to get it running.
  1. Provisioning the Cloud Environment
    Before touching Jenkins, I needed a reliable host. I spun up an Amazon Linux EC2 instance, utilizing the t2.micro size for free-tier eligibility. The most crucial part of this step was properly configuring the AWS Security Group to manage inbound traffic:
I allowed SSH traffic on Port 22 so I could connect to the instance from my local terminal.
I opened Custom TCP on Port 8080, which is the default port Jenkins requires to serve its web interface.
When downloading the .pem key pair for SSH access, running chmod 400 on the file is an essential step to secure the permissions and prevent SSH rejection errors.
  1. Installing Java and Jenkins
    Because Jenkins is fundamentally a Java-based application, installing the Java Development Kit (JDK) was the mandatory first step. I updated the EC2 packages and installed the Java environment (specifically Amazon Corretto). After pulling down the official Jenkins repository, the installation ran smoothly.
Starting the Jenkins service and navigating to http://<my-ec2-public-ip>:8080 brought up the initial setup screen. Unlocking it required grabbing the auto-generated administrator password stored directly on the server at /var/lib/jenkins/secrets/initialAdminPassword.
  1. Building the Pipeline for PetClinic
    Instead of a basic placeholder script, I configured a full Jenkins pipeline to pull the PetClinic source code, execute the build, and integrate with Docker.
I wrote a Jenkinsfile to define specific, repeatable stages: Build, Test, and Containerize.
Integrating Docker meant the pipeline packaged the compiled application alongside its runtime environment, ensuring consistency across deployments.
Monitoring the Jenkins console output and watching each pipeline stage turn green as the PetClinic Docker image successfully compiled was incredibly rewarding.
Key Takeaways for Beginners
If you are preparing to build your first CI/CD pipeline, here is what I learned:
Nail the Infrastructure First: Getting your AWS EC2 networking and Security Group rules right is just as important as the pipeline syntax itself.
Leverage Plugins Wisely: Jenkins relies heavily on plugins to extend its functionality, such as integrating directly with GitHub and Docker. Installing the default suggested plugins during setup provides a solid baseline.
Use Declarative Pipelines: Writing a structured Jenkinsfile (a Declarative Pipeline) is much easier to version control, read, and debug than manually clicking through freestyle job configurations in the UI.
To the other student builders in the community: what was the very first application you successfully automated using Jenkins? Drop your experiences in the comments!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article