java continuous integration testing environment release

java continuous integration testing environment release

1. Install jenkins

2. Install gitlab

3.idea import code (spring official website to download Eureka)

1. Download
https://spring.io/projects/spring-cloud-schema-registry#samples
https://github.com/spring-cloud/spring-cloud-stream-samples/tree/master/schema-registry -samples
Here Insert Picture Description
Here Insert Picture Description

4. Local git repo arranged to gitlab

4.1 git installation configuration generation sshkey

config --global the user.name Git "your username"
Git --global user.email config "[email protected]"
SSH-keygen -t RSA -C "[email protected]"
Press Enter 3, the password is air.

4.2 in C: \ Users \ user.ssh directory and id_rsa.pub generate id_rsa

Paste files to copy id_rsa.pub shown in FIG.

Here Insert Picture Description

4.3 New projects will be pushed to the source gitlab

Download the corresponding item in the right-bash git
git the init
.git the Add Remote git github Origin [email protected]/ your username / warehouse name
git the Add.
Commit -m "commit reasons of" git
git the Push -u Origin Master

The automatic detection of the configuration code changes gitlab jenkins

5.1 configuration using maven project jenkins

Other default configuration here intercept some configuration screenshots
Here Insert Picture Description
Here Insert Picture Description

5.2 allows gitlab use webhook

Here Insert Picture Description

5.3 Configuring jenkins new maven project url

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

6. Configure build deployment script jenkins

6.1 jenkins Configuration

Here Insert Picture Description

6.2 script content (this script reference csdn Forum hosaos Author)

app=$1
#port=$2
path=/opt
#echo this is app : $app
echo port : $port
#若项目已启动,杀死旧进程
api_pid=`ps -ef | grep "$app.jar" | grep -v grep | awk '{print $2}'`
echo api_pid = $api_pid

if [ "$api_pid" != "" ]; then
        echo kill api
        kill -9 $api_pid

        echo sleep 3s
        sleep 1
        echo sleep 2s
        sleep 1
        echo sleep 1s
        sleep 1
fi

#将jar包从jenkins工作空间中移动到指定路径下
mv /root/.jenkins/workspace/$app/target/$app.jar $path/$app
cd $path/$app
chmod +x $app.jar

#防止进程被杀死
BUILD_ID=dontKillMe
#后台进程形式启动项目
#nohup java -jar -Dserver.port=$port -Xmx256m -Xms128m  $app.jar &

nohup java -jar -Xmx256m -Xms128m  $app.jar &
echo $app start success
exit 0

7 compiler validation service deployment

Changing the Port
Here Insert Picture Description
after commit push the code

Here Insert Picture DescriptionPage Views success

Published an original article · won praise 0 · Views 24

Guess you like

Origin blog.csdn.net/weixin_38907835/article/details/104797788