說明:
Source files:Source files的目錄是基於當前job的目錄(可以從jenkins的安裝目錄下找到):例如當前job名稱為people-info-server,則對於root用戶,Source files中的目錄是相對於/var/jenkins_home/workspace/people-info-server目錄下的,因此,如果我們要發送people-info-server下的xx項目的jar包,這里需要填寫:xx/target/xx-0.0.1.SNAPSHOT.jar
Remove prefix:表示需要移除的目錄,比如這里填寫xx/target,則表示發布時,只把xx-0.0.1.SNAPSHOT.jar發布到遠程linux,而不包含xx/target目錄結構
Remote directory:表示需要把編譯好的war包發布到遠程linux的哪個目錄下
Exec command:需要執行的shell命令,shell命令在遠程linux服務器上.
注意:
job名稱不能和項目名稱相同,否則上傳不了
附上shell腳本(Post Steps – SSH Publishers–Transfers–Exec command):
-
echo "hello address-distribution-1.0.0.jar"
-
-
DAY=`date +%Y-%m-%d`
-
-
pid=`ps -ef|grep address-distribution-1.0.0|grep -v grep|awk '{print $2}'`
-
-
if [ -n "$pid" ]
-
then
-
echo 'The pid: server' $pid ' will be killed....'
-
kill -9 $pid
-
echo 'The pid: server' $pid ' will be start'
-
cp /home/warehousecloud/.jenkins/workspace/zjs-dzfd-web/target/address-distribution-1.0.0.jar /data/sonar-jenkins/ test-jar
-
echo 'copy /home/warehousecloud/.jenkins/workspace/zjs-dzfd-web/target/address-distribution-1.0.0.jar to /data/sonar-jenkins/test-jar '
-
nohup java -jar /data/sonar-jenkins/ test-jar/address-distribution-1.0.0.jar > /dev/null &
-
else
-
echo 'The pid: server' $pid ' not exist , will be start'
-
nohup java -jar /data/sonar-jenkins/ test-jar/address-distribution-1.0.0.jar > /dev/null &
-
fi
-
echo 'The pid: server' $pid ' started'
成功界面: