1. 程式人生 > >Jenkins部署java項目實例02

Jenkins部署java項目實例02

lean 觸發 ets lee 部署java項目 url start 實例 http

源碼管理 選擇 “git”, Repository URL填寫你的git地址,並配置對應的key,大家最好事前先在jenkins這臺機器上能夠直接遠程git操作私有倉庫 構建觸發器、構建環境、Pre Steps保持默認 技術分享圖片 Build “Root POM”為pom.xml, Goals and options 填寫 clean install -D maven.test.skip=true Post Steps、構建設置保持默認 技術分享圖片 技術分享圖片 構建 執行 shell 技術分享圖片 jenkins 上 分發腳本內容
[root@jenkins-ansible-jumpserver sh]# cat deploy_weifeng_dev.sh 
#!/bin/bash


# kill tomcat進程
tomcat_fashion_bi_dev_pid=`ps aux|grep weifeng|grep -v "grep"|awk ‘{print $2}‘`

if [ "$tomcat_fashion_bi_dev_pid" ];then
    ps aux|grep weifeng|grep -v "grep"|awk ‘{print $2}‘|xargs kill -9 
    echo "old tomcat weifeng dev  process  is killed"
fi


rm -rf  /home/deploy/weifeng/dev/deploy_files/*

echo "delete old  project files /home/deploy/weifeng/dev/deploy_files"


#解壓war包到 代碼執行地方

cd /home/deploy/weifeng/dev/
unzip -oq deepfashion-fashionbi.war -d /home/deploy/weifeng/dev/deploy_files/


#重啟tomcat
cd /home/deploy/tomcat_weifeng_dev/bin
sh startup.sh

sleep 5
tomcatport=` netstat -lntp|grep "8080"|awk ‘{print $4}‘|awk -F":" ‘{print $2}‘`
echo $tomcatport

if [ "$tomcatport" ];then
          echo -e "\033[32m[ tomcat weifeng started success on dev env !  ]\033[0m"
fi

  

Jenkins部署java項目實例02