Jenkins Build on EC2
Last updated
Last updated
Let's Setup the build environment by deploying Jenkins on EC2 as Build Server
For our build environment we’ll launch an Amazon EC2 instance using the Amazon Linux 2 AMI, install and configure the required packages. Make sure that the security group you select for your instance allows traffic on ports TCP/22 and TCP/80 so you will be able to connect to you instance via SSH and access it via browser using its DNS.
Install and configure Jenkins and required packages
Connect to your EC2 instance using your private key:
First, let’s update the repositories and install Docker and Git:
Add the Jenkins repository and install Jenkins from there:
To allow Jenkins to build our Docker images, we need to add the jenkins user to the docker group:
Add the Jenkins and Docker services to start on boot and start both services:
As Jenkins typically uses port TCP/8080, we’ll configure iptables routing rules to redirect the traffic:
I’m not covering the usage of SSL certificates, to use HTTPS you need to include rules to redirect traffic for port 443:
You can find more about SSL certificates on this article from Paul Lessing:Single-Page Apps on AWS, Part 1: Hosting a Website on S3 How to set up S3, CloudFront and CloudFlare to host a static website on S3 without a dedicated server.medium.com
At this point you should be able to see the Jenkins home page using the public DNS name of your EC2 instance(e.g. ec2–<ec2-public-ip-address>.compute-1.amazonaws.com):Jenkins Setup — Administrator password
Get the password from the indicated file:
Install the recommended plugins and create an Admin account in the following steps.
At this point you should be able to login an see the following page:Jenkins home page
Install Jenkins Plugins
At the Jenkins home page on the left menu select Manage Jenkins -> Manage Plugins select the tab Available and search for the following plugins:
Blue Ocean - New Jenkins UI
Pipeline AWS - AWS Integration