持续集成工具Jenkins

Linux下有两种使用方式今天介绍一种 哈哈 !!后期补上!!

1:开篇点题,先要有环境。

      配置 java 环境

      export JAVA_HOME=/usr/local/tools/jdk1.8.0_131

      export JRE_HOME=${JAVA_HOME}/jre

      export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

      export  PATH=${JAVA_HOME}/bin:$PATH

     

      配置 maven 环境

      export MAVEN_HOME=/usr/local/tools/maven-3.5.3

      export MAVEN_HOME

      export PATH=$PATH:$MAVEN_HOME/bin

2:a.下载 Jenkins.war 扔到 tomcat 的下。即 :webapps 下

      b.启动tomcat(这里是默认端口8080)  访问你的tomcat -->  http:192.168.xxx.xxx:8080/jenkins

持续集成工具Jenkins      

      c.如上图所示:默认管理员密码在 /root/.jenkins/secrets/initialAdminPassword 下

         cat /root/.jenkins/secrets/initialAdminPassword 或者 vim /root/.jenkins/secrets/initialAdminPassword 

         复制密码登录即可

#! /bin/bash  
ttomcat_status=`ps -ef | grep tomcat-lianyun | grep -v grep| awk '{print $2}'`

if [[ $ttomcat_status -gt 0 ]];then
   kill -9 $ttomcat_status
 fi
   rm -rf /opt/haolei/web/tomcat-lianyun/webapps/lianyun.war
   mv /var/lib/jenkins/workspace/haolei_dev/sound-haolei-machine-lianyun/target/sound-haolei-machine-lianyun.war /opt/haolei/web/tomcat-lianyun/webapps/lianyun.war
   cp /opt/haolei/web/tomcat-lianyun/webapps/lianyun.war /opt/haolei/bak/lianyun.war.$version.`date "+%Y%m%d%H%M%S"`.bak
   sleep 3

     bash /opt/haolei/web/tomcat-lianyun/bin/startup.sh
export JAVA_HOME=/usr/local/jdk
/haolei/tomcat-lianyun/bin/shutdown.sh
rm -rf /haolei/tomcat-lianyun/webapps/lianyun
mv /haolei/tomcat-lianyun/webapps/sound-haolei-machine-lianyun.war /haolei/tomcat-lianyun/webapps/lianyun.war
cp /haolei/tomcat-lianyun/webapps/lianyun.war /haolei/bak/lianyun.war.$version.`date "+%Y%m%d%H%M%S"`.bak
sleep 3
ps -ef | grep tomcat-lianyun | grep -v grep| awk '{print $2}'|xargs kill -9
/haolei/tomcat-lianyun/bin/startup.sh
/opt/haolei/server/sound-haolei-core-server-0.0.1-SNAPSHOT/bin/stop.sh
rm -rf /opt/haolei/server/*
cp /var/lib/jenkins/workspace/haolei_dev/sound-haolei-core-server/target/sound-haolei-core-server-0.0.1-SNAPSHOT-assembly.tar.gz  /opt/haolei/server -a
cd /opt/haolei/server
whoami
sleep 10
tar zxvf sound-haolei-core-server-0.0.1-SNAPSHOT-assembly.tar.gz 
whoami
/opt/haolei/server/sound-haolei-core-server-0.0.1-SNAPSHOT/bin/start.sh
whoami

相关推荐