jenkins執行shell腳本,找不到環境變量

問題如摘要描述;問題緣由分析參考 jenkins找不到環境變量java

    解決方案:在須要執行的腳本前加上 /bin/bash -l  使當前登錄用戶以登錄模式執行腳本文件nginx

    案例:/bin/bash -l /opt/tomcat/tomcat1601/restart1601.shweb

restart1601.sh中的一個坑tomcat

    啓動tomcat須要先找到tomcat pid 殺掉進程再啓動,剛開始寫了一個腳本在本機執行能夠,可是在jenkins中執行就直接失敗了 緣由是殺進程的時候把grep本身也殺掉了,而後ssh斷開鏈接bash

     可用的腳本以下app

restart1601.shssh

#!/bin/bash
#echo "stop tomcat1601..."
rm -rf /opt/tomcat/tomcat1601/webapps/sinterface
ps -ef|grep tomcat1601|grep "java"|awk  '{print "kill -9 " $2}' |sh
#echo "kill tomcat1601"
/bin/bash /opt/tomcat/tomcat1601/bin/startup.sh
#echo "start up tomcat1601..."

補充問題:webapp

    當發佈後 拷貝新的war包到tomcat/webapps下 重啓tomcat以前須要將原來解壓的項目文件夾刪除,不然tomcat啓動時不會從新解壓新的war包rest

相關文章
相關標籤/搜索