欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

持续集成工具Jenkins

程序员文章站 2022-07-09 15:50:07
...

 

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

 

      

      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

 

 

export JAVA_HOME=/usr/java/jdk1.8.0

portal_status=`ps -ef | grep portal.jar | grep -v grep| awk '{print $2}'`  
  
if [[ $portal_status -gt 0 ]];then  
   kill -9 $portal_status  
fi  
   rm -rf /home/ifrs9_bak/portal.war  

 

pro_path=/home/ifrs9_bak

mv /root/.jenkins/workspace/zframe-portal/target/portal.war $pro_path/portal.war 

cp $pro_path/portal.war $pro_path/portal.war.$version.`date "+%Y%m%d%H%M%S"`.bak

cd $pro_path

nohup java -server -Xms512m -Xmx1024m -jar portal.war --spring.profiles.active=test >portal.log &  

tail -f portal.log