How to Install and Configure Jenkins on AnonVM: A Step-by-Step Guide

How to Install and Configure Jenkins on AnonVM: A Step-by-Step Guide

Jenkins is one of the most popular automation servers used by software development teams to implement continuous integration (CI) and continuous delivery (CD) pipelines. With Jenkins, you can automate tasks like building, testing, and deploying applications, making it a key tool for DevOps. In this tutorial, we'll show you how to install Jenkins on your AnonVM server, configure it, and set up a simple project build pipeline.

Prerequisites

Before we begin, ensure that you have the following:

  • AnonVM VPS or Dedicated Server: A server with root or sudo access running on AnonVM.
  • Operating System: Jenkins supports various Linux distributions like Ubuntu, Debian, and CentOS.
  • Java: Jenkins requires Java, so ensure you have Java installed on your server.
  • A Web Browser: To access the Jenkins dashboard.

Step 1: Update Your System

It's important to start by updating your server’s software. This will ensure you have the latest security patches and updates.

For Ubuntu/Debian-based systems:

sudo apt update sudo apt upgrade -y

For CentOS-based systems:

sudo yum update -y

Step 2: Install Java Development Kit (JDK)

Jenkins requires Java to run. You can install the default JDK available on your distribution or a specific version like OpenJDK 11.

For Ubuntu/Debian:

sudo apt install -y openjdk-11-jdk

For CentOS:

sudo yum install -y java-11-openjdk-devel

Once Java is installed, verify the installation:

java -version

You should see an output similar to:

openjdk version "11.0.10" 2021-01-19 OpenJDK Runtime Environment (build 11.0.10+9) OpenJDK 64-Bit Server VM (build 11.0.10+9, mixed mode)

Step 3: Add Jenkins Repository

Jenkins provides its own repository for installation. To ensure you install the latest stable version, you'll need to add Jenkins’s official repository.

For Ubuntu/Debian-based systems:

  1. Add the Jenkins repository key:

     
    wget -q -O - https://pkg.jenkins.io/jenkins.io.key | sudo apt-key add -
  2. Add the Jenkins repository:

     
    sudo sh -c 'echo deb http://pkg.jenkins.io/debian/ stable main > /etc/apt/sources.list.d/jenkins.list'
  3. Update the package list:

     
    sudo apt update

For CentOS-based systems:

  1. Add the Jenkins repository:

     
    sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
  2. Import the Jenkins GPG key:

     
    sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key

Step 4: Install Jenkins

Now that we’ve added the Jenkins repository, it's time to install Jenkins.

For Ubuntu/Debian-based systems:

sudo apt install -y jenkins

For CentOS-based systems:

sudo yum install -y jenkins

Step 5: Start Jenkins Service

Once Jenkins is installed, start the Jenkins service.

For Ubuntu/Debian-based systems:

sudo systemctl start jenkins

For CentOS-based systems:

sudo systemctl start jenkins

Step 6: Enable Jenkins to Start on Boot

To ensure Jenkins starts automatically after a server reboot, enable the Jenkins service.

For Ubuntu/Debian-based systems:

sudo systemctl enable jenkins

For CentOS-based systems:

bash
sudo systemctl enable jenkins

Step 7: Open Jenkins in Your Browser

By default, Jenkins runs on port 8080. To access the Jenkins web interface, open your web browser and navigate to:

http://your_server_ip:8080

You should see the Jenkins setup wizard. If you’re prompted for an unlock key, you can find it in the following file:

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

Copy the key, paste it into the setup wizard, and continue the setup process.

Step 8: Install Suggested Plugins

Jenkins will ask if you want to install the suggested plugins. It’s generally a good idea to select "Install suggested plugins" to get a set of useful plugins that will help you get started quickly.

Step 9: Create the First Admin User

Once the plugins are installed, Jenkins will prompt you to create the first admin user. Fill in the details to create a user for accessing Jenkins.

  • Username: admin
  • Full name: Admin
  • Password: (Choose a strong password)

Click Save and Finish to complete the installation.

Step 10: Access Jenkins Dashboard

Once Jenkins is set up, you can access the Jenkins dashboard by navigating to:

http://your_server_ip:8080

Log in with the credentials you just created.

Step 11: Configure Jenkins for Your Projects

Now that Jenkins is installed and running, you can start configuring it for your projects. Here’s how to create a simple build job:

  1. From the Jenkins dashboard, click on New Item.
  2. Enter a name for the job, select Freestyle project, and click OK.
  3. In the configuration screen, you can configure various build options:
    • Source Code Management: Connect to a Git repository.
    • Build Triggers: Set up automatic build triggers, such as GitHub webhook or periodic build.
    • Build: Add build steps such as executing a shell script or running Maven/Gradle tasks.

Step 12: Set Up Jenkins Notifications (Optional)

You can configure Jenkins to send notifications in case of build successes or failures. Jenkins supports several notification plugins, including email and Slack integration.

To configure email notifications, follow these steps:

  1. Go to Manage JenkinsConfigure System.
  2. Scroll down to the E-mail Notification section.
  3. Fill in your SMTP server details, and click Test Configuration to ensure everything works correctly.

Step 13: Secure Jenkins (Optional but Recommended)

For better security, especially if Jenkins is exposed to the internet, you should consider securing it with HTTPS and restricting access with authentication.

  1. Install SSL certificates and configure Jenkins to use HTTPS.
  2. Restrict access using Jenkins' built-in security or integrate with external tools like LDAP.

Conclusion

You’ve successfully installed and configured Jenkins on your AnonVM server. With Jenkins set up, you can now automate the building, testing, and deployment of your software projects, improving the efficiency and reliability of your development pipeline.

Key Takeaways:

  • Jenkins enables automation of CI/CD workflows, reducing manual effort and increasing productivity.
  • Plugins: Jenkins offers a rich ecosystem of plugins for integration with various tools and services.
  • Security: Always ensure your Jenkins server is properly secured, especially if exposed to the public internet.

Now you’re ready to start automating your projects with Jenkins on your AnonVM server!

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution