Jenkins+Maven打成jar包,并执行

说明:
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'

成功界面:

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

技术武器库

一句真诚的谢谢,胜过千言万语

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值