Describe how Jenkins deployed jar type projects (SpringBoot)

*****1. Configure the environment

  1. Git git git git git git git git

  2. \

  3. \

*****2. Create a task (project)

\

*****3, source management, git address, and authentication configuration, click add, add username and password \

\

\

*****4. Focus on scripts

#! /bin/bash cd /deploy_cmp_script echo “Execute shell Start” sh stop.sh sh replace.sh echo “Execute shell Finish” chmod 777 /deploy_cmp_script/startup.sh BUILD_ID=dontKillMe nohup /deploy_cmp_script/startup.sh &

Three file contents

==================stop.sh===start=======================

#! Stop the app #! stop.sh #! /bin/bash cd /deploy_cmp_script echo “Stopping SpringBoot Application for CMP” ls pid=`ps -ef | grep CMP – 0.0.1 – the SNAPSHOT. Jar | grep -v grep | awk ‘{print $2}’ ` if [-n “$pid”] then #! Kill -9 Forcibly terminate the PID of echo “kill -9 :” $pid kill -9 $pid fi\

==================stop.sh===end =======================

\

==================replace.sh===start=======================

Jar_name = CMP – 0.0.1 – the SNAPSHOT. Jar #! Compiled jar package storage address file_path = ~ /. Jenkins/workspace/CMP/target #! After backing up the existing JARS, Jar “if [-f “$file”] then mv /deploy_cmp/ cmp-0.0.1-snapshot.jar / deploy_cmp_backup/CMP – 0.0.1 – the SNAPSHOT. Jar. ` date + % % m % d % Y H ` fi cp % m % S ~ /. Jenkins/workspace/CMP/target/CMP – 0.0.1 – the SNAPSHOT. Jar/deploy_cmp \

==================replace.sh===end =======================

\

==================startup.sh===start=======================

Ehco “Grant permissions to current user” chmod 777 /deploy_cmp/cmp-0.0.1- snapshot. jar echo “Run…..” CD/deploy_cmp Java jar CMP – 0.0.1 – the SNAPSHOT. Jar echo “* * * * * * * * * * * * * * * * * * * * * * CMP on Jenkins started*************************”\

==================startup.sh===end =======================\

\

After the application is saved, build the project directly. \

\