前提:
svn环境搭建:参考博客 《SVN版本管理搭建(svn+apache+svnadmin)》
Maven私服搭建:参考博客《使用Nexus搭建Maven私服》
jenkins环境安装
①安装 JDK 并配置环境变量,参考博客:《Linux下安装jdk1.7》
②Maven本地仓库的安装(使用 Maven 作为项目构建与管理工具):
(1)下载 maven-3.0.5
# wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
(2)解压:
# tar -zxvf apache-maven-3.0.5-bin.tar.gz
# mv apache-maven-3.0.5 maven-3.0.5
(3)配置 Maven 环境变量:
# vi /etc/profile
## maven env
export MAVEN_HOME=/root/maven-3.0.5
export PATH=$PATH:$MAVEN_HOME/bin
# source /etc/profile
(4)Maven 本地库配置,settings.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/root/maven-3.0.5/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<offline>false</offline>
<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
<pluginGroup>org.jenkins-ci.tools</pluginGroup>
</pluginGroups>
<!--配置权限,使用默认用户-->
<servers>
<server>
<id>nexus-releases</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
<mirrors>
</mirrors>
<profiles>
<profile>
<id>edu</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>1.7</jdk>
</activation>
<repositories>
<!-- 私有库地址-->
<repository>
<id>nexus</id>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!--插件库地址-->
<pluginRepository>
<id>nexus</id>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Example for MySQL-->
<sonar.jdbc.url>
jdbc:mysql://localhost:3306/sonarqube?useUnicode=true&characterEncoding=utf8
</sonar.jdbc.url>
<sonar.jdbc.username>root</sonar.jdbc.username>
<sonar.jdbc.password>123456</sonar.jdbc.password>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://localhost:9090/sonarqube
</sonar.host.url>
</properties>
</profile>
</profiles>
<!--激活profile-->
<activeProfiles>
<activeProfile>edu</activeProfile>
</activeProfiles>
</settings>
③安装tomcat
(1)下载最新版 Tomcat7,当前最新版为 7.0.59:
# wget http://apache.fayea.com/tomcat/tomcat-7/v7.0.59/bin/apache-tomcat-7.0.59.tar.gz
(2)解压安装 Tomcat:
# tar -zxvf apache-tomcat-7.0.59.tar.gz
# mv apache-tomcat-7.0.59 jenkins-tomcat
移除/root/jenkins-tomcat/webapps 目录下的所有文件:
# rm -rf /root/jenkins-tomcat/webapps/*
(3)将 Tomcat 容器的编码设为 UTF-8:
# vi /root/jenkins-tomcat/conf/server.xml
<Server port="8035" shutdown="SHUTDOWN">
<Connector port="8088" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
<Connector port="8036" protocol="AJP/1.3" redirectPort="8443" />
不配置utf-8编码,进入jenkins会报提示
④安装 jenkins
(1)下载最新版的 jenkins包:
下载地址: https://jenkins-ci.org
(2)将 war 包拷贝到 jenkins-tomcat/weapps
目录下
(3)防火墙开启 8088 端口,用 root 用户修改/etc/sysconfig/iptables.
# vi /etc/sysconfig/iptables
增加:
## jenkins-tomcat port:8088
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8088 -j ACCEPT
重启防火墙:
# service iptables restart
(4)启动 jenkins-tomcat
# /root/jenkins-tomcat/bin/startup.sh
浏览器输入:http://192.168.17.168:8088/jenkins/
5)如上图所示,需要将该文件下的密码,写入密码所在的文件如上图红色的地方
(6)进入选择插件安装界面,选择第一个(Install suggested plugins)(最好建议在网好的时候安装,安装了好几次,都是插件下载的不全吧,进去之后有错,蛋疼)
(7)插件安装完成之后,需要创建第一个用户,我这里使用admin好记
(8)创建用户之后,就可以使用jenkins了
⑤配置 jenkins
配置内容很多,为了更方便让大家都能看懂,搞了很多图片