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
  • Connecting with EC2 from Jenkins
  • Pre-requisites
  • Publish Code to EC2

Was this helpful?

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

Jenkins CI with EC2

PreviousJenkins CI - S3NextJenkins CI Cluster Mode

Last updated 5 years ago

Was this helpful?

Lets push code to EC2 Remote Server from Jenkins Build Server

Connecting with EC2 from Jenkins

If you want to run commands on the AWS EC2 Instance tool using Jenkins, this blog can help you to connect your self-hosted Jenkins with AWS EC2 Instance, using the SSH remote host plugin provided by Jenkins.

Pre-requisites

  1. One Up & Running AWS – EC2 Instance

  2. One UP & Running Jenkins Server

  3. AWS EC2 Public IP Address

  4. AWS EC2 Pem File

Step 1

  • Go to: Jenkins -> Manage Jenkins -> Manage Plugins -> Available Tab

  • Search For ‘SSH Plugin‘

  • Download and Install that Plugin

The plugin shall appear in the installed tab.

Step 2

  • Go to: Jenkins -> Manage Jenkins -> Configure System

Now “SSH remote hosts” option will appear on this page.

  • “Add” button will appear in the SSH remote hosts section.

  • This plugin can connect multiple EC2 Instances.

  • Add button will ask for a number of parameters as described in the image above.

Parameter Values

  • Hostname: Public IP of EC2 Instance or any Domain name of EC2 Instance

  • Port: 22 ‘Because 22 Port is for SSH Connections’

  • pty, serverAliveInterval, timeout: put the value as described in above image

  • Need to Add Credentials by clicking Add button next to Credentials Drop Down.

Step 3

  • Add Credentials Popup will appear as explained in the image above.

Parameter Values

  • Kind: SSH Username with Private Key

  • Scope: Global

  • Username: ec2-user ‘or Any Username of your AWS EC2 Instance’

  • Private Key: Select ‘Enter directly’. Here we will add Pem file

    • Key: Open Pem file with text -> Copy Content -> Paste here.

  • Passphrase: leave it blank

  • ID: leave it blank

  • Description: Put any Name for your Connection.

Step 4

  • Back to SSH remote hosts in Manage Jenkins -> Configure System.

  • Select the credentials that you created recently.

  • Then hit ‘Check Connection’ Button.

Publish Code to EC2

Step 1 : Configure correctly a jenkins job ready to build your app in remote ec2 machine.

  • Using this plugin add new remote server under Publish over SSH section in Manage Jenkins >> Configure System option.

  • Now create some jenkins job. Then, in build section add a step called : Send files or execute commands over SSH

Install this plugin in your jenkins platform :

enter image description here
Publish Over SSH Plugin
linux server talking to jenkins server
configure git repo
add build now