{"id":28049,"date":"2018-09-11T03:13:47","date_gmt":"2018-09-11T08:13:47","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=28049"},"modified":"2022-12-09T03:31:02","modified_gmt":"2022-12-09T09:31:02","slug":"how-to-install-jenkins-on-debian-9","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-jenkins-on-debian-9\/","title":{"rendered":"How to Install Jenkins on Debian 9"},"content":{"rendered":"
<\/p>\n
Jenkins is an open source extensible automation server which can be used as a simple CI server (Continuous Integration) or as a CD hub (Continuous Delivery). In this tutorial we are going to show you how to install Jenkins on a Linux VPS<\/a> running Debian 9 as an operating system.<\/p>\n <\/p>\n In order to run Jenkins on your server, you need to have Jenkins can be used to automate all sorts of tasks, from building and testing to developing and deploying software. Its functionality can be extended through hundreds of plugins while you can configure it via its web interface.<\/p>\n Jenkins runs on different platforms and operating systems. On a Debian 9 VPS<\/a> it can be easily installed through the To install Jenkins on your server running Debian 9 as an operating system, you need to have root access to it. If you have root access to the server, you should\u00a0connect to the server via SSH<\/a> and update the already installed software to the latest version by using the following commands:<\/p>\n This will update the package index and will update the software to the latest version available.<\/p>\n Next, we will be installing stable LTS version of Jenkins so we should add the appropriate repository. Run the following commands to do so:<\/p>\n Once you add the repository update the package index once again:<\/p>\n Finally, install Jenkins by running the command below:<\/p>\n If you get the following error while installing Jenkins:<\/p>\n It means you don’t have Now that the installation of Jenkins is completed, it is good to know how you can manage the Jenkins service. To start the Jenkins service, run the following command in the terminal:<\/p>\n To stop the Jenkins service, you can use the following command:<\/p>\n To restart the service, you can run the following command:<\/p>\n To check the status of the Jenkins service, run the following command:<\/p>\n If Jenkins is up and running on your Linux VPS<\/a> at the moment, the output will be similar to the one below:<\/p>\n To enable the Jenkins service on system boot, run the following command:<\/p>\n In case you want Jenkins disabled on system boot, run the following command:<\/p>\n Jenkins by default listens on port Replace the line<\/p>\n with<\/p>\n Where Now open your favorite web browser and access the Jenkins web interface by typing your server IP address followed by the port number in the search bar. The page will be similar to the one below.<\/p>\n <\/p>\n If this is what you are seeing on your screen, it means you need to unlock Jenkins. You can find the password to unlock Jenkins in the Enter the password and click on Continue<\/strong>. You can now continue and install the plugins needed for your projects.<\/p>\n <\/p>\n A good starting point is to read the Jenkins user documentation<\/a> where you can find many instructions and usage examples.<\/p>\nPrerequsites<\/h3>\n
Java<\/code> installed. If you don’t have Java installed, you can check our tutorial about how to install Java on Debian 9<\/a>. Also you need to have root access to the server or system user with sudo privileges<\/a>.<\/p>\n
apt<\/code> package manager.<\/p>\n
Install Jenkins on a Debian 9 VPS<\/h3>\n
apt-get update \r\napt-get upgrade<\/pre>\n
wget -q -O - https:\/\/pkg.jenkins.io\/debian\/jenkins.io.key | sudo apt-key add -\r\nsh -c 'echo deb http:\/\/pkg.jenkins.io\/debian-stable binary\/ > \/etc\/apt\/sources.list.d\/jenkins.list'<\/pre>\n
apt-get update<\/pre>\n
apt-get install jenkins<\/pre>\n
host jenkins[2747]: ERROR: No Java executable found in current PATH: \/bin:\/usr\/bin:\/sbin:\/usr\/sbin\r\nhost jenkins[2747]: If you actually have java installed on the system make sure the executable is in the aforementioned path and that 'type -p java' returns the java executable path\r\nhost systemd[1]: jenkins.service: Control process exited, code=exited status=1\r\n<\/pre>\n
Java<\/code> installed on your Debian VPS<\/a>. Go back to the prerequisites<\/strong> section for instructions on how to install
Java<\/code> on your machine.<\/p>\n
Manage Jenkins on Debian 9<\/h3>\n
systemctl start jenkins.service<\/pre>\n
systemctl stop jenkins.service<\/pre>\n
systemctl restart jenkins.service<\/pre>\n
systemctl status jenkins.service<\/pre>\n
# systemctl status jenkins.service\r\n\u25cf jenkins.service - LSB: Start Jenkins at boot time\r\n Loaded: loaded (\/etc\/init.d\/jenkins; generated; vendor preset: enabled)\r\n Active: active (exited) since Mon 2018-09-10 11:24:25 CDT; 2min 35s ago\r\n Docs: man:systemd-sysv-generator(8)<\/pre>\n
systemctl enable jenkins.service<\/pre>\n
systemctl disable jenkins.service<\/pre>\n
Access and Configure Jenkins on Debian 9<\/h3>\n
8080<\/code>. If you have another service listening on that port, Jenkins will fail to start. In that case you need to edit the
\/etc\/default\/jenkins<\/code> file.<\/p>\n
----HTTP_PORT=8080----<\/pre>\n
----HTTP_PORT=8081----<\/pre>\n
8081<\/code> is the number of the port where you want Jenkins to listen to. Then restart Jenkins.<\/p>\n
systemctl restart jenkins.service<\/pre>\n
\/var\/lib\/jenkins\/secrets\/initialAdminPassword<\/code> file.<\/p>\n
cat \/var\/lib\/jenkins\/secrets\/initialAdminPassword<\/pre>\n
\n