CentOS7下svn+tomcat9.0+maven3.3+jenkins实现web项目自动构建与远程发布
CentOS 7操作系统(CentOS-7-x86_64-DVD-1503-01.iso)
下载地址:http://ftp.riken.jp/Linux/centos/7/isos/x86_64/
下载地址:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Apache Tomcat(apache-tomcat-9.0.0.M1.tar.gz)
下载地址:http://tomcat.apache.org/download-90.cgi
maven(apache-maven-3.3.9-bin.tar.gz)
下载地址:http://maven.apache.org/download.cgi
jenkins(jenkins.war)
下载地址:https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins
Deploy to container Plugin(deploy-1.0.phi)
下载地址:https://updates.jenkins-ci.org/download/plugins/deploy/
以上软件包集合下载地址:http://pan.baidu.com/s/1c1xnUfu
[root@localhost tmp]# mkdir -p /usr/local/java
[root@localhost tmp]# mv jdk-8u65-linux-x64.tar.gz /usr/local/java
[root@localhost tmp]#cd /usr/local/java/
[root@localhost java]#tar -xvzf jdk-8u65-linux-x64.tar.gz
……
[root@localhost java]# rm -rf jdk-8u65-linux-x64.tar.gz
环境变量配置
[root@localhost java]# vim /etc/profile
添加如下内容:
#added by shouke
export JAVA_HOME=/usr/local/java/jdk1.8.0_65
export JRE_HOME=/usr/local/java/jdk1.8.0_65/jre
CLASSPATH=.:$JAVA_HOME/lib/dr.jar:$JAVA_HOME/lib/tools.jar:
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
[root@localhost bin]# source /etc/profile
查看是否安装成功
[root@localhost java]# java -version
java version "1.8.0_65"
SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
[root@localhost java]#javac -version
javac 1.8.0_65
参考连接:
http://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jdk.html#BJFJJEFG
[root@localhost tmp]#tar -xvzf apache-tomcat-9.0.0.M1.tar.gz
……
[root@localhost tmp]# mkdir -p /usr/local/apache-tomcat
[root@localhost tmp]# mv apache-tomcat-9.0.0.M1 /usr/local/apache-tomcat/
环境变量配置:
[root@localhost java]# vim /etc/profile
……
#added by shouke
export JAVA_HOME=/usr/local/java/jdk1.8.0_65
export JRE_HOME=/usr/local/java/jdk1.8.0_65/jre
export CATALINA_BASE=/usr/local/apache-tomcat/apache-tomcat-9.0.0.M1
export CATALINA_HOME=/usr/local/apache-tomcat/apache-tomcat-9.0.0.M1
CLASSPATH=.:$JAVA_HOME/lib/dr.jar:$JAVA_HOME/lib/tools.jar:
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$CATALINA_BASE:$CATALINA_HOME
[root@localhost bin]# source /etc/profile
设置管理员帐号密码
[root@localhost apache-tomcat-9.0.0.M1]# ls
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[root@localhost apache-tomcat-9.0.0.M1]# cd conf/
[root@localhost conf]# vim tomcat-users.xml
找到如下内容
在其下新增用户和角色
问题:怎么知道角色是啥角色呢?如下,点击对应按钮,点击取消,
如下,它会告诉你怎么做的
可根据实际情况设置,修改后的文件配置如下
说明:admin用户可以访问Server Status,Manager App,Host Manager
, hostadmin只可访问Host Manager
启动Apache Tomcat
[root@localhost tmp]# cd /usr/local/apache-tomcat/apache-tomcat-9.0.0.M1/
[root@localhost apache-tomcat-9.0.0.M1]# cd bin
[root@localhost bin]# sh startup.sh
Using CATALINA_BASE: /usr/local/apache-tomcat/apache-tomcat-9.0.0.M1
Using CATALINA_HOME: /usr/local/apache-tomcat/apache-tomcat-9.0.0.M1
Using CATALINA_TMPDIR: /usr/local/apache-tomcat/apache-tomcat-9.0.0.M1/temp
Using JRE_HOME: /usr/local/java/jdk1.8.0_65/jre
Using CLASSPATH: /usr/local/apache-tomcat/apache-tomcat-9.0.0.M1/bin/bootstrap.jar:/usr/local/apache-tomcat/apache-tomcat-9.0.0.M1/bin/tomcat-juli.jar
Tomcat started.
[root@localhost bin]#
防火墙开放默认的8080端口
[root@localhost bin]#firewall-cmd --permanent --zone=public --add-port=8080/tcp
success
[root@localhost bin]#firewall-cmd --reload
访问测试
[root@localhost tmp]# mkdir -p /usr/local/maven
[root@localhost tmp]# tar -xvzf apache-maven-3.3.9-bin.tar.gz
……
[root@localhost tmp]# mv apache-maven-3.3.9 /usr/local/maven/
环境变量设置
[root@localhost tmp]#vim /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_65
export JRE_HOME=/usr/local/java/jdk1.8.0_65/jre
export CATALINA_BASE=/usr/local/apache-tomcat/apache-tomcat-9.0.0.M1
export CATALINA_HOME=/usr/local/apache-tomcat/apache-tomcat-9.0.0.M1
export MAVEN_HOME=/usr/local/maven/apache-maven-3.3.9
CLASSPATH=.:$JAVA_HOME/lib/dr.jar:$JAVA_HOME/lib/tools.jar:
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$CATALINA_BASE:$CATALINA_HOME:$MAVEN_HOME/bin
[root@localhost tmp]# source /etc/profile
查看是否安装成功
[root@localhost tmp]# mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/maven/apache-maven-3.3.9
Java version: 1.8.0_65, vendor: Oracle Corporation
Java home: /usr/local/java/jdk1.8.0_65/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-229.el7.x86_64", arch: "amd64", family: "unix"
参考连接:http://maven.apache.org/install.html
[root@localhost tmp]# ls
jenkins.war
[root@localhost tmp]# cp jenkins.war /usr/local/apache-tomcat/apache-tomcat-9.0.0.M1/webapps/
重启apache tomcat服务器
[root@localhost bin]# sh /usr/local/apache-tomcat/apache-tomcat-9.0.0.M1/bin/shutdown.sh
[root@localhost bin]# sh sh /usr/local/apache-tomcat/apache-tomcat-9.0.0.M1/bin/startup.sh
访问jenkins
1)系统管理-系统设置
2)系统管理-安全设置
提交后如下
注册并登陆