<\/span><\/h2>\r\n\r\n\r\n\r\nFirst, log in to your Ubuntu 20.04 server via SSH as the root user:<\/p>\r\n\r\n\r\n\r\n
ssh root@IP_Address -p Port_number<\/pre>\r\n\r\n\r\n\r\nYou will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the admin account if necessary.<\/p>\r\n\r\n\r\n\r\n
Before starting, you have to make sure that all Ubuntu OS packages installed on the server are up to date. You can do this by running the following commands:<\/p>\r\n\r\n\r\n\r\n
apt-get update -y\r\napt-get upgrade -y<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 2: Install Java<\/span><\/h2>\r\n\r\n\r\n\r\nJenkins is a java-based application. So Java must be installed in your system if not installed you can install it using the following command:<\/p>\r\n\r\n\r\n\r\n
apt-get install default-jdk -y<\/pre>\r\n\r\n\r\n\r\nThis will install the Java version 11 in your system. You can verify the Java version with the following command:<\/p>\r\n\r\n\r\n\r\n
java -version<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
openjdk version \"11.0.9.1\" 2020-11-04\r\nOpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04)\r\nOpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)\r\n<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 3: Install Jenkins<\/span><\/h2>\r\n\r\n\r\n\r\nBy default, Jenkins is not available in the Ubuntu standard repository so you will need to add the jenkins repository to your system.<\/p>\r\n\r\n\r\n\r\n
First, install the necessary dependencies with the following command:<\/p>\r\n\r\n\r\n\r\n
apt-get install apt-transport-https gnupg2 -y<\/pre>\r\n\r\n\r\n\r\nNext, download and add the GPG key with the following command:<\/p>\r\n\r\n\r\n\r\n
wget -q -O - https:\/\/pkg.jenkins.io\/debian\/jenkins.io.key | apt-key add -<\/pre>\r\n\r\n\r\n\r\nNext, add the Jenkins repository with the following command:<\/p>\r\n\r\n\r\n\r\n
sh -c 'echo deb http:\/\/pkg.jenkins.io\/debian-stable binary\/ > \/etc\/apt\/sources.list.d\/jenkins.list'<\/pre>\r\n\r\n\r\n\r\nOnce the repository is added, update the repository cache and install the Jenkins with the following command:<\/p>\r\n\r\n\r\n\r\n
apt-get update -y\r\napt-get install jenkins -y<\/pre>\r\n\r\n\r\n\r\nAfter installing Jenkins, verify the status of Jenkins using the command below:<\/p>\r\n\r\n\r\n\r\n
systemctl status jenkins<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
\u25cf jenkins.service - LSB: Start Jenkins at boot time\r\n Loaded: loaded (\/etc\/init.d\/jenkins; generated)\r\n Active: active (exited) since Mon 2020-12-21 05:34:22 UTC; 6s ago\r\n Docs: man:systemd-sysv-generator(8)\r\n Tasks: 0 (limit: 2353)\r\n Memory: 0B\r\n CGroup: \/system.slice\/jenkins.service\r\n\r\nDec 21 05:34:20 ubuntu2004 systemd[1]: Starting LSB: Start Jenkins at boot time...\r\nDec 21 05:34:21 ubuntu2004 jenkins[15472]: Correct java version found\r\nDec 21 05:34:21 ubuntu2004 jenkins[15472]: * Starting Jenkins Automation Server jenkins\r\nDec 21 05:34:21 ubuntu2004 su[15526]: (to jenkins) root on none\r\nDec 21 05:34:21 ubuntu2004 su[15526]: pam_unix(su-l:session): session opened for user jenkins by (uid=0)\r\nDec 21 05:34:21 ubuntu2004 su[15526]: pam_unix(su-l:session): session closed for user jenkins\r\nDec 21 05:34:22 ubuntu2004 jenkins[15472]: ...done.\r\nDec 21 05:34:22 ubuntu2004 systemd[1]: Started LSB: Start Jenkins at boot time.\r\n<\/pre>\r\n\r\n\r\n\r\nJenkins is now running and listening on port 8080. You can verify it with the following command:<\/p>\r\n\r\n\r\n\r\n
ss -antpl | grep 8080<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
LISTEN 0 50 *:8080 *:* users:((\"java\",pid=15539,fd=141)) \r\n<\/pre>\r\n\r\n\r\n\r\n