Jenkins: The OpenSource CICD weapon for a better  operation of your infrastructure

Jenkins: The OpenSource CICD weapon for a better operation of your infrastructure

·

5 min read

Introduction to Jenkins and its Benefits

Looking to streamline your software development process? Jenkins is here to save the day! This powerful automation tool is a game-changer for teams looking to enhance their continuous integration and delivery practices. In this blog post, I'll guide you through the process of installing Jenkins on an EC2 instance on AWS. Let's dive in and unleash the full potential of Jenkins together!

Setting up an EC2 Instance on AWS

Setting up an EC2 instance on AWS is the first step towards leveraging the power of Jenkins for your continuous integration and deployment needs. To begin, log in to your AWS account and navigate to the EC2 dashboard. Click on "Launch Instance" to start the instance creation process.

Next, choose an Amazon Machine Image (AMI) that suits your requirements. Select an instance type based on the computational resources you need for running Jenkins smoothly. Configure security groups to control access to your instance by defining inbound and outbound rules.

After configuring storage options, review your settings and launch the EC2 instance. Make sure to create or use existing key pairs for secure access via SSH. Once launched, note down the Public DNS or IP address for connecting to your EC2 instance.

With these steps completed, you are now ready to proceed with installing Java and setting up Jenkins on your newly created EC2 instance!

Let's connect to this machine now...

SSH into the EC2 instance

The command to connect or ssh into this instance is simple.

ssh -i <keypair name> <username@publicip address of the instance>

Since the IP address of the machine that I created was 34.228.30.172, the user name was ec2-user (since it was Amazon Linux), and my keypair name was jenkins.pem, my SSH command turned out to be:

ssh -i jenkins.pem ec2-user@34.228.30.172

Let's update this EC2 instance now. Run the command below:

sudo yum update

Since my EC2 instance was already on the newest version with all the updates installed, the command line displayed me a message that there was "Nothing to do", else this command would run a couple of checks and install all the dependencies.

Installing Java on the EC2 Instance

So, you've set up your EC2 instance on AWS and now it's time to get Java installed. Java is a key component for running Jenkins smoothly on your server.

To install Java on your EC2 instance, you can use the package manager specific to your Linux distribution. For example, since I was using the Amazon Linux, I ran the command sudo dnf install java-17-amazon-corretto -y.

Once Java is successfully installed, make sure to verify the installation by running java -version in the terminal. This command should display the version of Java that was just installed.

Now that Java is ready to go, we can move forward with downloading and configuring Jenkins on our EC2 instance for seamless automation workflows!

Downloading and Configuring Jenkins

Now that you have your EC2 instance up and running with Java successfully installed, it's time to move on to the next step: downloading and configuring Jenkins.

Head over to the official Jenkins website and download the latest version of Jenkins. Once the download is complete, SSH into your EC2 instance and navigate to the directory where Jenkins was downloaded.

Next, run the command to start Jenkins using Java; this will initiate the installation process. Make sure to follow any prompts or instructions that may appear during installation. Here are the steps that I took to install Jenkins:

Start the Jenkins and enable the service

After successful installation, open a web browser and access Jenkins by entering your EC2 instance's public IP address followed by port 8080 (e.g., http://your-ec2-ip-address:8080). You will be prompted to enter an initial admin password generated during setup - follow instructions on-screen.

Now run the command below to see the admin password for the first login:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Once you enter the admin password on the Unlock Jenkins page, you will be able to see this:

I selected the first option "Install suggested plugins":

Upon successful login, configure basic settings such as creating an admin account and selecting plugins for additional functionalities.

Ignore the warning message in the screenshot, as that email address was rectified.

And there you have it—Jenkins is now downloaded and configured on your EC2 instance!

Conclusion and Next Steps

Installing Jenkins on an EC2 instance on AWS opens up a world of possibilities for continuous integration and continuous delivery. With Jenkins, you can automate your software development processes, increase productivity, and ensure the quality of your codebase.

As a next step after setting up Jenkins on your EC2 instance, explore the various plugins available to customize and enhance its functionality. Additionally, consider integrating Jenkins with other tools in your development pipeline to further streamline your workflows.

By leveraging the power of Jenkins and AWS together, you can take your software development practices to the next level. Stay updated with best practices in utilizing Jenkins for CI/CD pipelines to continually improve efficiency and quality in your projects.

Oh yes!! I forgot to tell you the most important thing: if you want to continue learning about Jenkins, like creating jobs, setting up pipelines, etc., keep the EC2 instance running. Otherwise, if you just want to learn how to install Jenkins, please make sure that you terminate the instance to avoid unnecessary bills.

Happy Learning!