安装方法很简单:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
如果在执行 sudo apt-get install jenkins
中出现如下报错:
invoke-rc.d: initscript jenkins, action "start" failed.
● jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-01-30 22:39:31 PST; 14ms ago
Docs: man:systemd-sysv-generator(8)
Process: 13548 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILURE)
Jan 30 22:39:31 ubuntu systemd[1]: Starting LSB: Start Jenkins at boot time...
Jan 30 22:39:31 ubuntu jenkins[13548]: ERROR: No Java executable found in current P...in
Jan 30 22:39:31 ubuntu jenkins[13548]: If you actually have java installed on the s...th
Jan 30 22:39:31 ubuntu systemd[1]: jenkins.service: Control process exited, code=e...s=1
Jan 30 22:39:31 ubuntu systemd[1]: Failed to start LSB: Start Jenkins at boot time.
Jan 30 22:39:31 ubuntu systemd[1]: jenkins.service: Unit entered failed state.
Jan 30 22:39:31 ubuntu systemd[1]: jenkins.service: Failed with result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package jenkins (--configure):
subprocess installed post-installation script returned error exit status 1
Processing triggers for systemd (229-4ubuntu21.4) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)
说明Jenkins没有在/usr/bin下找到jdk相关文件。可以通过创建软链接解决此问题。
sudo ln -s /jdk安装文件/ /usr/bin/java
在执行sudo apt-get install jenkins
就算是安装完了。