1、安装jdk环境
root@ubuntu-node1:~
root@ubuntu-node1:/usr/local/src
root@ubuntu-node1:/usr/local/src
root@ubuntu-node1:/usr/local/src
root@ubuntu-node1:~
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
root@ubuntu-node1:~
root@ubuntu-node1:~
java version "1.8.0_301"
Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.301-b09, mixed mode)
2、安装jenkins
https://jenkins.io/zh/download/ #官方下载地址 https://mirrors.tuna.tsinghua.edu.cn/jenkins/debian-stable/ #ubuntu安装包清华源下载地址
2.1 通过deb包安装jenkins
root@ubuntu-node1:~
Selecting previously unselected package jenkins.
(Reading database ... 73420 files and directories currently installed.)
Preparing to unpack jenkins_2.332.1_all.deb ...
Unpacking jenkins (2.332.1) ...
Setting up jenkins (2.332.1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /lib/systemd/system/jenkins.service.
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for systemd (237-3ubuntu10.24) ...
2.1.1 启动jenkins
root@ubuntu-node1:~
root@ubuntu-node1:~
root@ubuntu-node1:~
jenkins 1873 0.0 0.1 76620 7608 ? Ss 11:12 0:00 /lib/systemd/systemd --user
jenkins 1874 0.0 0.0 111908 2556 ? S 11:12 0:00 (sd-pam)
jenkins 1888 0.0 0.0 20388 184 ? S 11:12 0:00 /usr/bin/daemon --name=jenkins --inherit --env=JENKINS_HOME=/var/lib/jenkins --output=/var/log/jenkins/jenkins.log --pidfile=/var/run/jenkins/jenkins.pid -- /usr/bin/java -Djava.awt.headless=true -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
jenkins 1889 5.2 14.1 3559776 567972 ? Sl 11:12 0:25 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
root 2155 0.0 0.0 14428 1024 pts/0 S+ 11:20 0:00 grep --color=auto jenkins
root@ubuntu-node1:~
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 1889 jenkins 158u IPv6 31886 0t0 TCP *:http-alt (LISTEN)
2.1.2 jenkins配置文件
root@ubuntu-node1:~
NAME=jenkins
JAVA_ARGS="-Djava.awt.headless=true"
PIDFILE=/var/run/$NAME/$NAME.pid
JENKINS_USER=$NAME
JENKINS_GROUP=$NAME
JENKINS_WAR=/usr/share/$NAME/$NAME.war
JENKINS_HOME=/var/lib/$NAME
RUN_STANDALONE=true
JENKINS_LOG=/var/log/$NAME/$NAME.log
JENKINS_ENABLE_ACCESS_LOG="no"
MAXOPENFILES=8192
HTTP_PORT=8080
PREFIX=/$NAME
JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT"
2.1.3 登入web界面
root@ubuntu-node1:~
687ecbc29a9343a192ed461bdf1dc0c8
2.1.3.1 jenkins离线问题解决
如果显示jenkins已离线,将以下文件中的更新检查地址改成国内清华大学地址,然后重启jenkins即可:https://mi rrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
</site>
</sites>
2.1.4 选择安装jenkins插件
2.1.5 Nginx代理配置
目前jenkins官方服务器在国外,从国内在线安装插件速度非常慢,但是可以通过Nginx进行rewrite,将安装插件 的请求通过清华大学镜像服务器,以实现插件安装加速,配置如下:
server {
listen 80;
server_name localhost;
location /download/plugins {
proxy_set_header Host mirrors.tuna.tsinghua.edu.cn;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite /download/plugins(.*) /jenkins/plugins/$1 break;
proxy_pass http://mirrors.tuna.tsinghua.edu.cn;
}
127.0.0.1 updates.jenkins-ci.org
2.1.6 安装插件过程
2.1.7 查看插件目录
root@ubuntu-node1:~
total 83644
drwxr-xr-x 88 jenkins jenkins 12288 Mar 14 17:53 ./
drwxr-xr-x 12 jenkins jenkins 4096 Mar 14 17:53 ../
drwxr-xr-x 7 jenkins jenkins 4096 Mar 14 17:50 ace-editor/
-rw-r--r-- 1 jenkins jenkins 4279042 Mar 14 17:50 ace-editor.jpi
drwxr-xr-x 4 jenkins jenkins 4096 Mar 14 17:50 ant/
drwxr-xr-x 4 jenkins jenkins 4096 Mar 14 17:48 antisamy-markup-formatter/
-rw-r--r-- 1 jenkins jenkins 243792 Mar 14 17:48 antisamy-markup-formatter.jpi
-rw-r--r-- 1 jenkins jenkins 84669 Mar 14 17:50 ant.jpi
drwxr-xr-x 4 jenkins jenkins 4096 Mar 14 17:51 apache-httpcomponents-client-4-api/
-rw-r--r-- 1 jenkins jenkins 1769549 Mar 14 17:51 apache-httpcomponents-client-4-api.jpi
drwxr-xr-x 6 jenkins jenkins 4096 Mar 14 17:49 bootstrap4-api/
-rw-r--r-- 1 jenkins jenkins 537677 Mar 14 17:49 bootstrap4-api.jpi
drwxr-xr-x 6 jenkins jenkins 4096 Mar 14 17:49 bootstrap5-api/
-rw-r--r-- 1 jenkins jenkins 481622 Mar 14 17:49 bootstrap5-api.jpi
drwxr-xr-x 4 jenkins jenkins 4096 Mar 14 17:50 bouncycastle-api/
--r-- 1 jenkins jenkins 759395 Mar 14 17:48 caffeine-api.jpi
2.1.8 创建账号
2.1.9 实例配置
2.1.10 登入
2.2 通过tomcat启动jenkins
root@ubuntu-node1:/apps
root@ubuntu-node1:/apps
root@ubuntu-node1:/apps
root@ubuntu-node1:/apps
/apps/apache-tomcat-8.5.50/bin/catalina.sh start
2.2.1 访问web界面
输入地址ip:8080/jenkins
2.3 通过war包直接启动jenkins
java \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=12345 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Djava.rmi.server.hostname="10.10.100.102" \
-jar jenkins.war &
2.3.1 访问web界面
|