inux下安裝jenkins有兩種方式:
1舶吗,通過rpm方式
2,通過war方式
本文是基于war方式欣孤,以下是war方式安裝的步驟:
1,下載安裝配置JDK環(huán)境姻檀;
具體操作查看筆者Linux下裝JDK筆錄:
http://www.reibang.com/p/5557fb0bc5d4
2闷煤,下載安裝配置Tomcat環(huán)境童芹;
具體操作查看筆者Linux安裝tomcat筆錄:
http://www.reibang.com/p/f62f75c00c97
3,下載安裝jenkins鲤拿;
1假褪,下載jenkins的war包:
去該地址下載想要安裝的版本:
http://mirrors.jenkins.io/war-stable/
這里筆者下載的是2.121.1版本
[root@iZj6c7eeosj2t5vjw8rf4xZ jenkins]# wget http://mirrors.shu.edu.cn/jenkins/war-stable/2.121.1/jenkins.war
2,把jenkins.war包放置到tomcat的webapps目錄下面近顷;
[root@iZj6c7eeosj2t5vjw8rf4xZ webapps]# cp -f /opt/frank/jenkins/jenkins.war /opt/tomcat/webapps/
[root@iZj6c7eeosj2t5vjw8rf4xZ webapps]# ls
docs examples host-manager jenkins.war manager ROOT tatoo
3,啟動tomcat生音;
啟動tomcat,tomcat會自動解壓war包窒升,生成一個jenkins文件夾缀遍,而且Jenkins默認(rèn)會存放在用戶主目錄下的.jenkins文件夾中。
如:Linux root用戶:/root/.jenkins
tomcat自動解壓生成jenkins文件查看:
[root@iZj6c7eeosj2t5vjw8rf4xZ webapps]# ls
docs examples host-manager jenkins jenkins.war manager ROOT tatoo
[root@iZj6c7eeosj2t5vjw8rf4xZ webapps]# cd jenkins
[root@iZj6c7eeosj2t5vjw8rf4xZ jenkins]# ls
bootstrap favicon.ico LogFileOutputStream$1.class MainDialog$1.class scripts
ColorFormatter.class help LogFileOutputStream$2.class MainDialog.class WEB-INF
css images LogFileOutputStream.class Main$FileAndDescription.class winstone.jar
dc-license.txt JNLPMain.class Main.class META-INF
executable jsbundles MainDialog$1$1.class robots.txt
jenkins的.jenkins文件位置
[root@iZj6c7eeosj2t5vjw8rf4xZ jenkins]# cd /root/.jenkins/
[root@iZj6c7eeosj2t5vjw8rf4xZ .jenkins]# ls
config.xml jenkins.install.UpgradeWizard.state nodes secrets
hudson.model.UpdateCenter.xml jobs plugins updates
identity.key.enc logs secret.key userContent
jenkins.CLI.xml nodeMonitors.xml secret.key.not-so-secret users
4饱须,如果不知道tomcat的訪問端口是什么可以通過以下命令:
[root@iZj6c7eeosj2t5vjw8rf4xZ .jenkins]# ps -ef|grep tomcat
root 1913 1883 0 Apr01 ? 01:14:19 java -jar /opt/frank/tomcat/apache-tomcat-8.5.23/melibs/cn-jufuns-ien-api-provider-1.0.0-local_dev.jar
root 18774 1 0 Apr12 ? 01:51:33 /usr/java/jdk1.8.0_144/jre/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -classpath /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat -Dcatalina.home=/opt/tomcat -Djava.io.tmpdir=/opt/tomcat/temp org.apache.catalina.startup.Bootstrap start
root 19027 17608 0 14:51 pts/0 00:00:00 grep tomcat
[root@iZj6c7eeosj2t5vjw8rf4xZ .jenkins]# netstat -apn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1432/sshd
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 2108/nginx
tcp 0 0 0.0.0.0:42395 0.0.0.0:* LISTEN 1894/java
tcp 0 0 127.0.0.1:32000 0.0.0.0:* LISTEN 1144/java
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 18774/java
tcp 0 0 0.0.0.0:2181 0.0.0.0:* LISTEN 1894/java
tcp 0 0 0.0.0.0:12200 0.0.0.0:* LISTEN 1913/java
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1766/php-fpm
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 18774/java
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 18774/java
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2108/nginx
tcp 0 0 172.31.195.1:57890 140.205.140.205:80 ESTABLISHED 19072/AliYunDun
tcp 0 0 127.0.0.1:31000 127.0.0.1:32000 ESTABLISHED 1144/java
tcp 0 2804 172.31.195.1:22 183.6.179.98:2048 ESTABLISHED 17606/sshd
tcp 0 0 127.0.0.1:2181 127.0.0.1:45840 ESTABLISHED 1894/java
tcp 0 0 127.0.0.1:45840 127.0.0.1:2181 ESTABLISHED 1913/java
tcp 0 0 127.0.0.1:32000 127.0.0.1:31000 ESTABLISHED 1142/wrapper
tcp 0 0 :::8989 :::* LISTEN 1803/python
tcp 0 0 :::3306 :::* LISTEN 1680/mysqld
udp 0 0 0.0.0.0:33848 0.0.0.0:* 18774/java
udp 0 0 0.0.0.0:68 0.0.0.0:* 942/dhclient
udp 0 0 172.31.195.1:123 0.0.0.0:* 1443/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 1443/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 1443/ntpd
udp 0 0 0.0.0.0:34999 0.0.0.0:* 1803/python
udp 0 0 0.0.0.0:5353 0.0.0.0:* 18774/java
udp 0 0 :::123 :::* 1443/ntpd
udp 0 0 :::8989 :::* 1803/python
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 20736497 19072/AliYunDun /tmp/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>
unix 2 [ ACC ] STREAM LISTENING 11161 1/init @/com/ubuntu/upstart
unix 2 [ ] DGRAM 11542 367/udevd @/org/kernel/udev/udevd
unix 5 [ ] DGRAM 12729 1021/rsyslogd /dev/log
unix 2 [ ACC ] STREAM LISTENING 9784 154/plymouthd @/ply-boot-protocol@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
unix 2 [ ACC ] STREAM LISTENING 14744 1680/mysqld /var/lib/mysql/mysql.sock
unix 2 [ ACC ] STREAM LISTENING 20736498 19072/AliYunDun /usr/local/aegis/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>
unix 3 [ ] STREAM CONNECTED 14909 1766/php-fpm
unix 2 [ ] STREAM CONNECTED 4213164 18774/java
unix 3 [ ] STREAM CONNECTED 17926 2108/nginx
unix 2 [ ] DGRAM 10537908 999/auditd
unix 3 [ ] STREAM CONNECTED 17927 2108/nginx
unix 3 [ ] STREAM CONNECTED 20736493 19072/AliYunDun
unix 3 [ ] STREAM CONNECTED 20736494 19072/AliYunDun
unix 3 [ ] STREAM CONNECTED 20736495 19072/AliYunDun
unix 2 [ ] DGRAM 14270 1443/ntpd
unix 2 [ ] STREAM CONNECTED 4213151 18774/java
unix 2 [ ] STREAM CONNECTED 13699 1144/java
unix 3 [ ] DGRAM 11556 367/udevd
unix 3 [ ] STREAM CONNECTED 14910 1766/php-fpm
unix 2 [ ] STREAM CONNECTED 15663 1894/java
unix 3 [ ] STREAM CONNECTED 12689 999/auditd
unix 2 [ ] STREAM CONNECTED 15669 1894/java
unix 2 [ ] STREAM CONNECTED 12920 1144/java
unix 3 [ ] STREAM CONNECTED 20736496 19072/AliYunDun
unix 3 [ ] STREAM CONNECTED 12688 999/auditd
unix 3 [ ] DGRAM 11555 367/udevd
unix 2 [ ] STREAM CONNECTED 15759 1913/java
unix 2 [ ] STREAM CONNECTED 16175 1913/java
unix 2 [ ] DGRAM 25634203 17606/sshd
ps -ef|grep java 和 netstat -apn命令:有上可知我們的tomcat端口是8080
4域醇,訪問jenkins界面:
在瀏覽器上輸入ip地址http://47.52.41.245:8080/jenkins(http://ip:端口/jenkins)即可訪問,如圖:
首次進(jìn)入jenkins如要輸入密碼,密碼位置:/root/.jenkins/secrets/initialAdminPassword
通過cat查看密碼,復(fù)制粘貼進(jìn)來譬挚,點擊繼續(xù)锅铅,進(jìn)入插件選擇安裝界面,點擊安裝默認(rèn)插件减宣,然后進(jìn)入插件安裝界面盐须,安裝完插件之后創(chuàng)建賬號然后登錄;
如果插件安裝失敗可以去鏡像地址下載插件漆腌,然后手動上傳
鏡像地址:https://mirrors.tuna.tsinghua.edu.cn/jenkins/