Now Hiring: Are you a driven and motivated 1st Line DevOps Support Engineer?

Jenkins Tutorial: Building & Deploying Code from GitHub Repositories to AWS EC2 Servers

Tech Articles

Jenkins Tutorial: Building & Deploying Code from GitHub Repositories to AWS EC2 Servers

Create a Freestyle Project for Beginners in Jenkins:

What is Jenkins?

Jenkins is an open-source automation server that simplifies and accelerates the software development process. Designed to be extensible and easy to use, Jenkins automates repetitive tasks such as building, testing, and deploying code. It seamlessly integrates with version control systems like Git and supports various plugins to adapt to your specific needs.

What is Git & GitHub?

Git, a distributed version control system, revolutionized how developers manage source code. It enables efficient tracking of changes, branching, and merging, fostering collaboration among team members.

GitHub, a remote platform built on Git, enhances this collaborative spirit by providing a centralized hub for hosting, sharing, and managing repositories.

What is Freestyle Project?

Jenkins Freestyle Project refers to a user-friendly feature in the Jenkins automation server that allows developers to configure and automate build and deployment tasks without the need for extensive scripting. It provides a point-and-click interface, making it accessible for both beginners and experienced developers, streamlining the process of continuous integration and automation in software development.

What is AWS EC2 Server?

Amazon Elastic Compute Cloud (EC2) is a web service offered by Amazon Web Services (AWS) that provides resizable compute capacity in the cloud. EC2 instances, commonly referred to as servers, allow users to run virtual machines with various configurations to meet specific computing requirements. These instances are scalable, enabling users to easily adjust computing resources based on demand, making AWS EC2 a flexible and widely-used solution for hosting applications, websites, and other computing workloads in the cloud


  • Jenkins installed with configured admin user and suggested plugins

STEP 1: Open the Jenkins

Access Jenkins via http://localhost:8080/. By default, Jenkins run on port 8080 if you didn’t specified another port for Jenkins.

Jenkins Dashboard

STEP 2: Install Publish Over SSH Plugin

Navigate to Jenkins Dashboard > Manage Jenkins > Plugins > Available Plugins > Search for ‘Publish Over SSH’. Install the plugin if not already done.

Publish Over SSH Plugin
  • Publish Over SSH plugin allows us to connect Jenkins to my AWS EC2 Server or any server with SSH Keys so we can further deploy and build our application on AWS EC2 server.

Step 3: Setup SSH Server on Jenkins

On Jenkins Dashboard, go to Manage Jenkins > Configure System > Search for ‘Publish Over SSH’.

You will see this

Publish Over SSH Configuration

Click on ‘Add’ Button.

Add SSH Server

Then you will see below screen with multiple fields required:

Let me explain how these values will be filled:

  • Name: Name of AWS EC2 Server
  • Hostname: Public IP of AWS EC2 Server
  • Username: From which user you will access the application in AWS server e.g john, sarah having rights.
  • Remote Directory: Specify the directory in which you want to deploy and build your code.

Now Click Test Configuration Button if its successful you are all set !!!

Test Configuration

Step 4: Create Freestyle Project

From Jenkins Dashboard

New Item > Select Freestyle Project (Enter the name and click OK)

Select project type

Now this is the main dashboard of your project configuration

Project dashboard

Now in this You can configure every things as you want

  • Add your own description
  • Your GitHub Repository
  • Your AWS server configuration
  • Build Command

and much more.

Step 5: Connect your GitHub Repository

In Source Code Management Section:

  • Select Git
  • Enter GitHub repository URL For instance, If you are using public GitHub repository then Credentials will be none If you are using private GitHub repository then you have to add credentials as you like in which format (Like Username password, secret text etc otherwise your repository cannot be accessed)
  • Specify the branch which you want to deploy and build.

Step 6: Add your Build Steps and environment

In Build Step Section:

  • Click on Add Build Step
Add Build Step
  • Select ‘Send Files or execute commands over SSH’.
  • Fill the following required fields:

In source Files:

  • If you want send all files then the syntax is just like above else you have to mention it like ‘**/*.jar’

In Remote directory:

  • You have to mention the desired path in your server in which you want to deploy your application

In Exec command:

  • Write the commands you want run on your server like npm install, npm run build etc or any linux command.

Then Click on Apply & Save and you are all set to build.

In project dashboard you have to click ‘Build now’ button and then BOOM !!

Build Now

If your all configurations are perfect then you will see this in ‘Build History’ section.


In conclusion, this Jenkins tutorial guides you through simple steps to automate building and deploying code from GitHub to AWS EC2 servers. Tailored for beginners, we explored the user-friendly Freestyle Project. Now equipped with these skills, you’re ready to introduce automation to your development projects.

Stay tuned and Follow for more DevOps tutorials and posts! 😊♾️


Leave your thought here

Your email address will not be published. Required fields are marked *