Step-by-Step Guide
- Update the Package Index
Open a terminal and update the package index to ensure you have the latest information about available packages:
sudo apt update
- Install Java
Jenkins requires Java to run. Install OpenJDK, which is a free and open-source implementation of the Java Platform:
sudo apt install openjdk-11-jdk
Verify the Java installation:
java -version
- Add Jenkins Repository
Add the Jenkins repository key to your system:
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
Add the Jenkins repository to your sources list:
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
- Update the Package Index Again
Update the package index to include the Jenkins repository:
sudo apt update
- Install Jenkins
Install Jenkins using theapt
package manager:
sudo apt install jenkins
- Start and Enable Jenkins
Start the Jenkins service:
sudo systemctl start jenkins
Enable Jenkins to start on boot:
sudo systemctl enable jenkins
- Verify Jenkins Installation
Check the Jenkins service status to ensure it is running:
sudo systemctl status jenkins
If Jenkins is running, you should see an active (running) status.
- Adjust the Firewall
Ensure that your firewall allows traffic on port 8080, which is the default port for Jenkins. If you are using UFW, you can allow traffic with:
sudo ufw allow 8080
sudo ufw status
- Access Jenkins Web Interface
Open your web browser and navigate tohttp://your_server_ip:8080
. You should see the Jenkins unlock screen. - Unlock Jenkins
Retrieve the initial administrator password by running the following command:sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password and paste it into the “Administrator password” field in the Jenkins web interface. - Install Suggested Plugins
After unlocking Jenkins, you will be prompted to install plugins. Click on “Install suggested plugins” to start the installation process. - Create First Admin User
Once the plugins are installed, you will be prompted to create the first admin user. Fill in the required information and click “Save and Finish”. - Start Using Jenkins
After creating the admin user, Jenkins is ready to use. Click on “Start using Jenkins” to access the Jenkins dashboard. - Configure Jenkins (Optional)
Configure Jenkins according to your needs. You can install additional plugins, set up credentials, and configure global settings from the Jenkins dashboard. - Set Up a Simple Job (Optional)
To set up a simple job, click on “New Item” in the Jenkins dashboard, enter a name for your job, select “Freestyle project”, and click “OK”. Configure the job settings and click “Save”. To run the job, click on “Build Now”.