Tapd + Tencent Worker Bee + Jenkins continuous deployment

Tpad associates with Tencent Worker Bee

tapd, project settings, pipeline settings
Insert picture description here
This URL is copied to: Tencent Worker Bee, project , project advanced settings, network callback hook
Insert picture description here

Server install git

It has been installed here, just to view.
Insert picture description here
git needs to configure the ssh key and set the local global account

    $ git config --global user.name "xxx"
    $ git config --global user.email "你的邮箱"

Generate secret key

    $ ssh-keygen -t rsa -C "你的邮箱"
    # 运行上面命令后,连续按3个回车(如果不需要密码的话)。

Then in the root/.ssh folder of the server, there will be an ssh secret key that
Insert picture description here
adds the pubpublic key to the personal settings of Tencent Worker Bee
Insert picture description here

Install Jenkins

You can install it directly with yum, or download the compressed package from the official website and upload it to the server for installation.
Insert picture description here
Then enter Jenkins through the server's public network address, set the initial password, install the recommended plug-in, and enter the main page.
Insert picture description here
Download the tapd Jenkins plug-in,
Insert picture description here
enter the Jenkins system management, plug-in management, advanced, upload the plug-in
Insert picture description here
Configure the global tapd plug-in ( picture from the Tapd document )
Picture from Tapd document
Insert picture description here

Field description:

  • Jenkins name: Give Jenkins a name, so that when TAPD manages Jenkins configuration, you can choose to call the corresponding Jenkins service according to the name (format requirements: 8-20 characters, please enter Chinese and English, underscore, English period and numbers, and only in Chinese and English beginning
  • Jenkins administrator: Fill in the Jenkins administrator account to manage the job construction
  • Jenkins access address: Please make sure that the current jenkins server has an external network access policy, and fill in the link address of the jenkins homepage that can be accessed from the external network (example: http://123.207.xx/jenkins) to support access to the current Jenkins from TAPD
  • Jenkins API Token: Generate token and fill in user managementInsert picture description here
  • Webhook address: Enter TAPD project settings-application settings, select [pipeline] configuration and get the address to fill in.
  • Secret Token: Enter TAPD project settings-application settings, select [pipeline] configuration and get it.

Tapd authorizes the Jenkins service: the name is arbitrary, and the access address is server address + port number
Insert picture description here

Configure the project environment

The environment required for the project pulled down by git, such as a vue project, or a springboot project.
Enter system management, global tool configuration,
Insert picture description here
configure the settings.xmlpath installed by maven,
Insert picture description here
Git, Node, Maven and other configurations are similar
Insert picture description here
Insert picture description here
Insert picture description here

Create Jenkins Job

Because here is a maven project, you need to install Maven Integrationplug-ins.
Insert picture description here
Associate tapd, fill in the tapd project id
Insert picture description here
Insert picture description here
parameter setting in the project , and the time is arbitrary.
Insert picture description here
Fill in the address of Tencent worker bee warehouse. Insert picture description here
Add the previously generated ssh key to
Insert picture description here
maven project construction in Credentials. You
Insert picture description here
can choose to build the trigger or not

Insert picture description here
The command executed after the build is completed.
Insert picture description here
The script in the command.

# 将之前部署的应用停止
# stop.sh
echo "Stopping SpringBoot Application"
pid=`ps -ef | grep demo-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then
   kill -9 $pid
fi
#replace.sh 用于将上次构建的结果备份,然后将新的构建结果移动到合适的位置
# 先判断文件是否存在,如果存在,则备份
# 运行项目的目录
file="/home/demo-0.0.1-SNAPSHOT.jar"
if [ -f "$file" ]
then
   mv /home/demo-0.0.1-SNAPSHOT.jar /home/backup/demo-0.0.1-SNAPSHOT.jar.`date +%Y%m%d%H%M%S`
fi
# 把Jenkins工作空间中打包好的文件移动到目标目录
mv /var/lib/jenkins/workspace/flips-2/target/demo-0.0.1-SNAPSHOT.jar /home/demo-0.0.1-SNAPSHOT.jar

Guess you like

Origin blog.csdn.net/qq_42007742/article/details/106787467