In this blog article, we will delve into the use of Jenkins for deploying continuous integration on the AWS platform.
1. Why Jenkins?
- Scalability: The cloud’s on-demand resource provisioning means Jenkins can scale without hardware limitations.
- Cost-Effective: Only pay for the compute resources you use.
- Collaboration: Cloud setups enable distributed teams to access the Jenkins CI/CD pipelines from anywhere.
2. Setting up Jenkins on a Cloud Platform (e.g., AWS EC2):
Step 1: Prerequisites
Before you begin, ensure you have the following:
- An AWS account: You need an AWS account to create and manage EC2 instances.
- AWS CLI (Command Line Interface): Install the AWS CLI on your local machine. You can find installation instructions here: AWS CLI Installation Guide.
Step 2: Launch an EC2 Instance
- Open your terminal or command prompt.
- Use the AWS CLI to launch an EC2 instance. Replace the placeholders with your actual values:
aws ec2 run-instances --image-id ami-0c55b159cbfafe1f0 --count 1 --instance-type t2.micro --key-name YourKeyName --security-group-ids your-security-group-id
ami-0c55b159cbfafe1f0
: This is the Amazon Machine Image (AMI) for an Amazon Linux 2 instance.t2.micro
: This is the instance type, which is in the AWS Free Tier.YourKeyName
: Replace this with the name of your AWS key pair.your-security-group-id
: Replace this with the security group ID you want to use for your instance.- Wait for the instance to be launched. You will receive information about the new instance, including its public IP address.
Step 3: Connect to the EC2 Instance
- Once the EC2 instance is running, use SSH to connect to it. Replace
YourKeyName.pem
with the path to your private key file andYOUR_EC2_PUBLIC_IP
with the instance’s public IP address:
ssh -i "YourKeyName.pem" ec2-user@YOUR_EC2_PUBLIC_IP
- You should now be connected to your EC2 instance.
Step 4: Install Jenkins
- Update the system’s packages and install Jenkins by running the following commands:
sudo yum update -y
sudo yum install jenkins -y
- Wait for Jenkins to be installed.
Step 5: Start Jenkins
- Start the Jenkins service with the following command:
sudo service jenkins start
- Jenkins is now running on your EC2 instance.
Step 6: Access Jenkins
- Open a web browser and navigate to
http://YOUR_EC2_PUBLIC_IP:8080
. ReplaceYOUR_EC2_PUBLIC_IP
with your instance’s public IP address. - You will be prompted to enter an initial admin password. To retrieve the password, SSH into your EC2 instance again and run:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- Copy the password and paste it into the Jenkins setup wizard in your browser.
- Follow the on-screen instructions to complete the Jenkins setup.
Step 7: Configure Jenkins
You can now configure Jenkins according to your needs, including setting up jobs, plugins, and integrations for your continuous integration and continuous delivery (CI/CD) pipelines.
That’s it! You’ve successfully deployed Jenkins on an AWS EC2 instance and can start using it for your automation and CI/CD tasks.
At GDS Consulting Services, we specialize in providing AWS infrastructure solutions. Feel free contact us for more information or visit our blog.