环境redhat6.5

安装包:

apache-maven-3.5.2-bin.tar.gz

apache-tomcat-9.0.1.tar.gz

jdk-9.0.1_linux-x64_bin.rpm

jenkins-2.88-1.1.noarch.rpm

下载地址:

http://maven.apache.org/download.cgi                                maven下载
https://pkg.jenkins.io/redhat/                                         jenkins下载
http://tomcat.apache.org/download-70.cgi                              tomcat下载
http://www.oracle.com/technetwork/java/javase/downloads/index.html    jdk下载


安装JDK    

[root@localhost ~]# rpm -ivh  jdk-9.0.1_linux-x64_bin.rpm

[root@localhost ~]# tail /etc/profile

unset i
unset -f pathmunge
export JAVA_HOME=/usr/local/java
export JRE_HOME=/usr/local/java/jre  
export PATH=$PATH:/usr/local/java/bin  
export CLASSPATH=./:/usr/local/java/lib:/usr/local/java/jre/lib


查看Java信息

[root@localhost ~]#java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)


安装apache-tomcat

[root@localhost ~]tar -zxvf  apache-tomcat-9.0.1.tar.gz -C  /usr/local/tomcat


安装jenkins

[root@localhost ~]rpm -ivh  jenkins-2.88-1.1.noarch.rpm


安装maven

[root@localhost python]#tar -zxvf apache-maven-3.5.2-bin.tar.gz

maven 是绿色软件只需解压就可以了

[root@localhost ~]#vim /etc/profile

加入以下内容:

export MAVEN_HOME=/tmp/python/apache-maven-3.5.2
export PATH=$MAVEN_HOME/bin:$PATH


重新加载环境变量

[root@localhost ~]#source /etc/profile


启动tomcat

[root@localhost ~]#/usr/local/tomcat/bin/startup.sh

Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/java/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.


浏览器窗口输入:http://192.168.112.119:8080/  可以访问tomcat

jdk+apache-tomcat+jenkins+maven+svn搭建_第1张图片


关闭tomcat

[root@localhost ~]#/usr/local/tomcat/bin/shutdown.sh

[root@localhost lib]# vim /etc/init.d/jenkins

******************

添加java安装目录

******************

candidates="
/usr/local/java
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/bin/java
"

[root@localhost ~]#service jenkins start

Starting Jenkins bash: /usr/local/java/: is a directory                 [FAILED]

阿偶出错了!!!


上面报错信息显示/usr/local/java是一个目录

所以是/etc/init.d/jenkins 添加了错误的java路径

先找JAVA在哪里。

[root@localhost lib]# find / -name java
/etc/alternatives/java
/etc/pki/ca-trust/extracted/java
/etc/pki/java
/service/jdk1.8.0_51/bin/java
/service/jdk1.8.0_51/com/sun/scenario/effect/impl/sw/java
/service/jdk1.8.0_51/com/sun/media/jfxmediaimpl/platform/java
/service/jdk1.8.0_51/jre/bin/java
/var/lib/alternatives/java
/usr/local/java   
/usr/bin/java

[root@localhost lib]# vim /etc/init.d/jenkins     添加红色信息
candidates="
/service/jdk1.8.0_51/bin/java
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/bin/java
"        

保存退出

[root@localhost ~]# service jenkins start
Starting Jenkins                                           [  OK  ]

[root@localhost ~]#/usr/local/tomcat/bin/startup.sh


浏览器输入http://192.168.112.119:8080/jenkins/

jdk+apache-tomcat+jenkins+maven+svn搭建_第2张图片


jdk+apache-tomcat+jenkins+maven+svn搭建_第3张图片

svn安装包:CollabNetSubversionEdge-5.1.0_linux-x86_64.tar.gz

绿色软件解压即可

[root@localhost ~]# tar -zxvf CollabNetSubversionEdge-5.1.0_linux-x86_64.tar.gz
[root@localhost ~]# mv csvn /application/

[root@localhost ~]# ln -s /application/csvn/bin/csvn /etc/init.d/csvn

[root@localhost ~]# ln -s /application/csvn/bin/csvn-httpd /etc/init.d/csvn-httpd

启动csvn和csvn-httpd

[root@localhost ~]# /etc/init.d/csvn start

[root@localhost ~]# /etc/init.d/csvn-httpd start

当然你也可以用service 启动 不过因为这里用的不是二进制安装包虽然在/etc/profile已经定义了javk的环境变量JAVA_HOME但是csvn也找不到JAVA 因此如果你想用service启动csvn的话,需要在csvn配置目录添加

export   JAVA_HOME=/usr/local/java.

[root@localhost ~]#mkdir -p /svn/{develop,test}

[root@localhost ~]# svnserve -d -r /svn/develop/

[root@localhost ~]#svnadmin create /svn/develop/

访问http://IP:3343/csvn/

用户名:admin

密码:admin


jdk+apache-tomcat+jenkins+maven+svn搭建_第4张图片


jenkin.war 部署

下载jenkins.war

清楚tomcat下webapps下的所有内容

[root@localhost tomcat-9.0]# rm -rf  /usr/local/tomcat/tomcat-9.0/webapps/*

如果觉得有必要刻意先备份一下webapps

上传jenkins.war到/usr/local/tomcat/tomcat-9.0/webapps/  目录下

重启tomcat

浏览器输入http://IP:8080/jenkins  访问



jdk+apache-tomcat+jenkins+maven+svn搭建_第5张图片

初始密码已经提示了在箭头所在的目录,直接黏贴上去即可

[root@localhost jenkins]# cat /root/.jenkins/secrets/initialAdminPassword
9e092648461b443f849bc99a18391a6f