jenkins安装部署实战
一.创建软件包目录并下载jdk
[root@jenkins ~]# mkdir /tools
[root@jenkins ~]# cd /tools/
[root@jenkins tools]# ls -l
总用量 190672
-rw-r--r--. 1 root root 4873043 12月 9 2014 apache-maven-3.0.4-bin.tar.gz
-rw-r--r--. 1 root root 9128610 8月 14 2016 apache-tomcat-8.0.27.tar.gz
-rw-r--r--. 1 root root 181238643 8月 14 2016 jdk-8u60-linux-x64.tar.gz
二.首先需要安装支持tomcat的jdk
[root@jenkins tools]# mkdir /application
[root@jenkins tools]# mv jdk1.8.0_60/ /application/
[root@jenkins tools]# ln -s /application/jdk1.8.0_60/ /application/jdk
三.安装tomcat软件
[root@jenkins tools]# tar xf apache-tomcat-8.0.27.tar.gz
[root@jenkins tools]# mv apache-tomcat-8.0.27 /application/
[root@jenkins tools]# ln -s /application/apache-tomcat-8.0.27/ /application/tomcat
四.设置JAVA环境变量
[root@jenkins tools]# tail -3 /etc/profile
export JAVA_HOME=/application/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@jenkins tomcat]# . /etc/profile
[root@jenkins tomcat]# java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
五.修改tomcat配置文件
[root@jenkins tomcat]# useradd -s /sbin/nologin -M tomcat
[root@jenkins tomcat]# id tomcat
uid=501(tomcat) gid=501(tomcat) 组=501(tomcat)
[root@jenkins tomcat]# /application/tomcat/bin/startup.sh
Using CATALINA_BASE: /application/tomcat
Using CATALINA_HOME: /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME: /application/jdk
Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@jenkins tomcat]# netstat -lntup|grep java
tcp 0 0 :::8009 :::* LISTEN 1625/java
tcp 0 0 :::8080 :::* LISTEN 1625/java
六.安装maven并配置变量
[root@jenkins tools]# tar xf apache-maven-3.0.4-bin.tar.gz
[root@jenkins tools]# mv apache-maven-3.0.4 /application/
[root@jenkins tools]# ln -s /application/apache-maven-3.0.4/ /application/maven
[root@jenkins tools]# vim /etc/profile
#maven环境变量
M2_HOME=/application/maven
PATH=$PATH:$M2_HOME/bin
export M2_HOME PATH
[root@jenkins tools]# . /etc/profile
[root@jenkins tools]# mvn -v
Apache Maven 3.0.4 (r1232337; 2012-01-17 16:44:56+0800)
Maven home: /application/maven
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /application/jdk1.8.0_60/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-573.el6.x86_64", arch: "amd64", family: "unix"
[root@jenkins tools]#
七. 下载jenkins的war包文件并放到tomcat的文件目录
[root@jenkins tools]# cd /application/tomcat/webapps/
[root@jenkins webapps]# ped
-bash: ped: command not found
[root@jenkins webapps]# pwd
/application/tomcat/webapps
[root@jenkins webapps]# wget http://mirrors.tuna.tsinghua.edu.cn/jenkins/war/2.46/jenkins.war
[root@jenkins bin]# /application/tomcat/bin/shutdown.sh
[root@jenkins bin]# /application/tomcat/bin/startup.sh #重新启动下tomcat
在浏览器中输入http://localhost:8080/jenkins/ 出现下图:
[root@jenkins secrets]# cat /root/.jenkins/secrets/initialAdminPassword
90890d075d5a40ff916e0b6a949c69b6 #此为初次登录验证密钥,输入管理员密码处确定
安装社区推荐的插件或者自定义选择插件,我这里直接选择第二个。