安装插件

  • 插件管理中安装 Maven Integration plugin

    全局工具配置

    Maven

    image.png

JDK

image.png

新建任务

选择构建一个maven项目
image.png

配置

image.png
image.png

  1. cp /root/.jenkins/workspace/growing_backend/target/growing_backend-1.0.0-SNAPSHOT.jar /home/nebula/workspace/growing_backend/growing_backend-1.0.0-SNAPSHOT.jar
  2. chmod 755 /home/nebula/workspace/growing_backend/growing_backend-1.0.0-SNAPSHOT.jar
  3. sh /home/nebula/workspace/growing_backend/stop.sh
  4. sh /home/nebula/workspace/growing_backend/start.sh

stop.sh

  1. #!/bin/sh
  2. PROCESS=`ps -ef | grep growing_backend-1.0.0-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`
  3. if [ "$PROCESS" ]
  4. then
  5. echo "kill $PROCESS"
  6. kill -9 $PROCESS
  7. else
  8. echo "no kill"
  9. fi

start.sh

  1. #!/bin/sh
  2. BUILD_ID=DONTKILLME
  3. cd /home/nebula/workspace/growing_backend
  4. nohup java -jar growing_backend-1.0.0-SNAPSHOT.jar > logs.log &