e2

滴滴侠,fai抖

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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

  1.  
    echo "hello address-distribution-1.0.0.jar"
  2.  
     
  3.  
    DAY=`date +%Y-%m-%d`
  4.  
     
  5.  
    pid=`ps -ef|grep address-distribution-1.0.0|grep -v grep|awk '{print $2}'`
  6.  
     
  7.  
    if [ -n "$pid" ]
  8.  
    then
  9.  
    echo 'The pid: server' $pid ' will be killed....'
  10.  
    kill -9 $pid
  11.  
    echo 'The pid: server' $pid ' will be start'
  12.  
    cp /home/warehousecloud/.jenkins/workspace/zjs-dzfd-web/target/address-distribution-1.0.0.jar /data/sonar-jenkins/test-jar
  13.  
    echo 'copy /home/warehousecloud/.jenkins/workspace/zjs-dzfd-web/target/address-distribution-1.0.0.jar to /data/sonar-jenkins/test-jar '
  14.  
    nohup java -jar /data/sonar-jenkins/test-jar/address-distribution-1.0.0.jar > /dev/null &
  15.  
    else
  16.  
    echo 'The pid: server' $pid ' not exist , will be start'
  17.  
    nohup java -jar /data/sonar-jenkins/test-jar/address-distribution-1.0.0.jar > /dev/null &
  18.  
    fi
  19.  
    echo 'The pid: server' $pid ' started'

成功界面:

posted on 2019-09-06 19:36  纯黑Se丶  阅读(1689)  评论(0编辑  收藏  举报