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:
For CentOS-based systems:
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:
For CentOS:
Once Java is installed, verify the installation:
You should see an output similar to:
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:
-
Add the Jenkins repository key:
-
Add the Jenkins repository:
-
Update the package list:
For CentOS-based systems:
-
Add the Jenkins repository:
-
Import the Jenkins GPG key:
Step 4: Install Jenkins
Now that we’ve added the Jenkins repository, it's time to install Jenkins.
For Ubuntu/Debian-based systems:
For CentOS-based systems:
Step 5: Start Jenkins Service
Once Jenkins is installed, start the Jenkins service.
For Ubuntu/Debian-based systems:
For CentOS-based systems:
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:
For CentOS-based systems:
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:
You should see the Jenkins setup wizard. If you’re prompted for an unlock key, you can find it in the following file:
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:
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:
- From the Jenkins dashboard, click on New Item.
- Enter a name for the job, select Freestyle project, and click OK.
- 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:
- Go to Manage Jenkins → Configure System.
- Scroll down to the E-mail Notification section.
- 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.
- Install SSL certificates and configure Jenkins to use HTTPS.
- 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!