jenkins automatic deployment environment

https://my.oschina.net/tonystark/blog/1920889

 

 

Sample script:

#!/bin/bash 

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

# Specify the location of the last compiled storage jar
www_path=/usr/local/shandie/java

Compiled #Jenkins good position jar
jar_path=/var/lib/jenkins/workspace/test-service/target/

#Jenkins in the name of the compiled jar
jar_name=sd-discover-eureka-0.0.1-SNAPSHOT.jar

# Get running compiled process ID, in time for us to re-deploy the project to kill the previous process
pid=$(cat /usr/local/shandie/java/shaw-test-web.pid)

# Compiled jar into the specified location
cd  ${jar_path}

# Copy the compiled jar to the last location specified
cp  ${jar_path}/${jar_name} ${www_path}

# Into the final position of the specified storage jar
cd  ${www_path}

# Kill process may have previously started projects
kill -9 ${pid}

# Start profiles jar, SpringBoot designated for test, background start
nohup java -jar  ${jar_name} &

# ID into the process to Shaw - web.pid file
echo $! > /usr/local/shandie/java/shaw-test-web.pid

 

The basic idea is to add a maven project, then go git branch to pull the project, and then compile and run the project script. Scripts to perform as needed

 

Guess you like

Origin www.cnblogs.com/huzi007/p/11969271.html