CI/CD Server Setup on Ubuntu 22.04 from Scratch

Introduction Setting up a CI/CD server on Ubuntu 22.04 from scratch can streamline your software development process. It automates the integration and...


0

Introduction

Setting up a CI/CD server on Ubuntu 22.04 from scratch can streamline your software development process. It automates the integration and delivery of your code, ensuring that new features and bug fixes are deployed efficiently. This guide will walk you through the server setup on Ubuntu for a powerful CI/CD pipeline. The server setup on Ubuntu involves installing various tools and configuring services to automate your workflows. This ensures that your applications are tested, built, and deployed seamlessly across environments. By focusing on server setup on Ubuntu, developers can create a robust environment for continuous integration and delivery.

Prerequisites

Before you begin the server setup on Ubuntu, ensure you have the following:

  • A fresh installation of Ubuntu 22.04
  • Root or sudo access to the server
  • Basic knowledge of Linux command line

You’ll also need a stable internet connection to download necessary packages and updates. Having access to your repository hosting service credentials (like GitHub or GitLab) is essential for setting up the CI/CD pipeline. With these prerequisites in place, you are ready to start the server setup on Ubuntu.

Step 1: Update and Upgrade the System

Start by updating and upgrading the system to ensure all packages are up-to-date. This is crucial for the server setup on Ubuntu.

sudo apt update && sudo apt upgrade -y

This command updates the package lists and upgrades the installed packages to their latest versions. Once your system is updated, you can proceed to install the necessary tools.

Step 2: Install Git

Git is a version control system essential for managing your codebase. Install Git to facilitate the server setup on Ubuntu.

sudo apt install git -y

This will allow you to clone repositories and manage version control directly on your server. With Git ready, you can now manage your code efficiently.

Step 3: Install Java

Many CI/CD tools, including Jenkins, require Java. Install Java to support these tools in your server setup on Ubuntu.

sudo apt install openjdk-11-jdk -y

Ensure Java is properly installed by checking its version.

java -version

This confirms that Java is ready for use. With Java installed, you can move on to setting up Jenkins.

Step 4: Install Jenkins

Jenkins is a popular automation server for CI/CD. To include Jenkins in your server setup on Ubuntu, follow these steps. First, add the Jenkins repository key and repository.

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

Then, update the package list and install Jenkins.

sudo apt update
sudo apt install jenkins -y

Start Jenkins and enable it to run at boot.

sudo systemctl start jenkins
sudo systemctl enable jenkins

Access Jenkins by entering your server’s IP address followed by port 8080 in a web browser. With Jenkins running, you’re ready to configure it.

Step 5: Configure Jenkins

During the initial setup, Jenkins will ask for an administrator password. Retrieve it using the following command.

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

Enter this password in the Jenkins web interface to continue the setup. Install suggested plugins and create an admin user to finalize the initial configuration. Once Jenkins is configured, you can enhance your server with Docker.

Step 6: Install Docker

Docker is necessary for containerizing applications, a vital part of modern CI/CD. Install Docker to enhance your server setup on Ubuntu.

sudo apt install docker.io -y

Add your user to the Docker group to execute Docker commands without sudo.

sudo usermod -aG docker $USER

Log out and back in to apply these changes. With Docker installed, you can easily handle containerized applications.

Step 7: Install Docker Compose

Docker Compose simplifies multi-container Docker applications, aligning with our server setup on Ubuntu.

sudo apt install docker-compose -y

Verify the installation by checking the version.

docker-compose --version

This ensures Docker Compose is operational. Now that Docker Compose is set up, you can test your CI/CD setup with a sample application.

Step 8: Set Up a Sample Application

Clone a sample application repository to test your CI/CD setup.

git clone https://github.com/someuser/sample-app.git
cd sample-app

This provides a working project to configure your CI/CD pipeline. With a sample application in place, you can create a Jenkins pipeline.

Step 9: Create a Jenkins Pipeline

In Jenkins, create a new pipeline to integrate your sample application. This step will help you test the full capabilities of your CI/CD server setup on Ubuntu, ensuring that all components work together seamlessly.


Like it? Share with your friends!

0

What's Your Reaction?

hate hate
0
hate
confused confused
0
confused
fail fail
0
fail
fun fun
0
fun
geeky geeky
0
geeky
love love
0
love
lol lol
0
lol
omg omg
0
omg
win win
0
win
Anoop Patel