DevOps Training
  • DevOps
  • What is DevOps
    • What DevOps Look like
    • Why DevOps Needed
    • DevOps Automation Tools
    • DevOps Principles
  • cloud computing
    • How DevOps links with Cloud Computing
    • What is cloud computing?
      • Platform as a service (PaaS)
      • Infrastructure as a service (IaaS)
      • Software as a service (SaaS)
      • Function as a Service
      • SaaS, PaaS, IaaS
  • Version Control
    • Git as Version Control
      • Setting up Remote Repo
      • Git Hooks
      • github vs gitlab vs bitbucket
      • Quick Recap Git
  • DevOps #01 Continuous Integration
    • Continuous Integration & Continuous Delivery
      • Understanding CI Tools
      • Prerequisite
      • Continuous Integration
      • CI Tools
      • Travis-CI
        • Travis CI with S3
        • Static Site Build S3
        • Beanstalk with AWS CLI
          • Elastic Beanstalk with Travis CI
        • Travis using Code Deploy EC2
          • Github and Code Deploy
          • Travis CI with Code Deploy
      • Gitlab-CI
        • CI Setup for application
        • Gitlab Runners on EC2
        • CI Integration with AWS
          • Deploying App using Gitlab CI
          • Gitlab CI with AWS S3
          • Gitlab CI with ECS
          • CI Integration with EC2
            • Update and Clean Gitlab.yml
        • Install Gitlab on EC2
      • CI/CD using Jenkins CI
        • Jenkins Build on EC2
        • Jenkins Build EC2 Ubuntu
        • Jenkins CI/CD
          • Create a Build Item
          • Create a Build Pipleine
            • Pipeline Using Docker
            • Pipeline Examples
          • Jenkins CI with S3
            • Jenkins CI - S3
          • Jenkins CI with EC2
    • Jenkins CI Cluster Mode
    • AWS Code Pipeline CI/CD
      • AWS CI/CD Tools
        • AWS Code Build
        • AWS Code Deploy to Beanstalk
        • AWS Code Deploy to EC2
        • AWS Pipeline - Example CI/CD
  • Docker
    • Docker
      • Docker for Developers
        • Install and setup
        • Docker Commands
        • Docker Images Container
        • Docker Architecture
    • Docker Demos
      • Node JS Container
    • Docker-compose
      • Using Docker Compose
      • Docker Compose Demo
  • AWS Quick Refresh
    • AWS Quick Recap - Videos
    • AWS Quick Recap
  • AWS Architecture - Lab
    • Application Deployment - 01
    • Application Deployment - 02
    • Application 3 tier Architecture
  • Basic Networking
    • Computer Networking for Beginners
      • Basic of Networking
      • Networking Protocols
      • OSI Model
      • Network address and Host address
      • Subnetting Type
    • Network Architecture
    • Networking Layers OSI Model
    • Internet protocol
      • CIDR and subnetting
        • Examples
      • AWS VPC Subnets
  • VPC and Networking
    • AWS VPC
    • VPC Demo
      • Bastion Host | Jump Server
  • AWS Components
    • AWS Components In Depth
      • AWS Storage
        • AWS EBS
        • AWS Cloudfront
        • AWS S3
      • AWS Compute
        • ECS
        • AWS VPC
          • VPC Components
        • AWS EC2
        • AWS ELB
          • Application Load balancer
            • Example
        • AWS EC2 Auto Scaling
          • Demo
        • AWS Route 53
        • AWS Lambda Serverless
          • AWS Lambda Serverless Computing
  • Assignments
    • Assignment 01-Node JS app on EC2
    • Assignment 02-Node JS with Mysql
    • Assignment-03
  • Microservices
    • Microservices Architecture
      • Docker and Docker-Compose
      • Docker-Compose Example 01
      • Docker-Compose Example 02
      • Hand-on | Building Microservices
    • Architecture Components
  • AWS ECS
    • AWS ECS
      • Introduction of ECS
Powered by GitBook
On this page

Was this helpful?

  1. DevOps #01 Continuous Integration
  2. Continuous Integration & Continuous Delivery
  3. CI/CD using Jenkins CI

Jenkins Build on EC2

PreviousCI/CD using Jenkins CINextJenkins Build EC2 Ubuntu

Last updated 5 years ago

Was this helpful?

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:

$ ssh -i "path-to-key/key.pem" ec2-user@<instance-name>.<instance-region>.compute.amazonaws.com

First, let’s update the repositories and install Docker and Git:

$ sudo yum update -y
$ sudo yum install -y docker git

Add the Jenkins repository and install Jenkins from there:

$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat/jenkins.repo
$ sudo rpm — import https://pkg.jenkins.io/redhat/jenkins.io.key
$ sudo yum install jenkins -y
$ sudo usermod -aG root jenkins # Add jenkins to the root group

To allow Jenkins to build our Docker images, we need to add the jenkins user to the docker group:

# Add Jenkins and current user to the Docker group
$ sudo usermod -aG docker $USER
$ sudo usermod -aG docker jenkins

Add the Jenkins and Docker services to start on boot and start both services:

# Add Jenkins and Docker to startup
$ sudo chkconfig jenkins on
$ sudo chkconfig docker on
$ sudo chkconfig --list
# Start Jenkins and Docker as a service
$ sudo service jenkins start
$ sudo service docker start

As Jenkins typically uses port TCP/8080, we’ll configure iptables routing rules to redirect the traffic:

$ sudo iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
$ sudo iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
$ sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

I’m not covering the usage of SSL certificates, to use HTTPS you need to include rules to redirect traffic for port 443:

$ sudo iptables -I INPUT 1 -p tcp --dport 8443 -j ACCEPT
$ sudo iptables -I INPUT 1 -p tcp --dport 443 -j ACCEPT
$ sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443

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:

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

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:

You can find more about SSL certificates on this article from :

- New Jenkins UI

- AWS Integration

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
Blue Ocean
Pipeline AWS