linux shell creation and start

1. Create a shell script, enter linux command:

touch my.sh

2. Edit the shell script, enter linux command:

we my.sh

3. Edit the shell script: By the way remember the commands that start automatically once Jenkins

#! / bin / bash 
# The above sentence is a must! 

BUILD_ID #export = dontKillMe this sentence is important so specified, it will not be killed Jenkins after the start of the project. 
BUILD_ID Export = dontKillMe 

# last specified position stored in the compiled jar 
www_path = / usr / Test / 

#Jenkins location in the compiled jar 
jar_path = / the root / .jenkins / Workspace / Platform / kid_cloud_platform / target 

#Jenkins compiled in jar name 
jar_name = Platform-1.0.0 .RELEASE.jar 

# get running compiled process ID, in time for us to re-deploy the project before the first kill process 
pid = $ (CAT / usr / the Test / codespace / Platform. PID) 

# compiled into the specified position jar 
CD jar_path} $ { 

# copy compiled jar to the final position designated 
CP jar_path} {$ / $ jar_name the {}} $ {www_path

# Final designated storage location jar 
cd $ www_path} { 

# kill before the start of the project may process 
the kill -9 $ {pid} 

# start profiles jar, SpringBoot designated for test, the background to start 
the Java -jar -Dspring.profiles. = $ {jar_name the Test the Active} & 

# ID process will be credited to rabbitmq.pid file 
echo $ !> /usr/test/codespace/platform.pid

4. authorize shell type linux command:

chmod +x my.sh

5. Run type linux command:

./my.sh

 

Guess you like

Origin www.cnblogs.com/lcmlyj/p/11113287.html