Tpad associates with Tencent Worker Bee
tapd, project settings, pipeline settings
This URL is copied to: Tencent Worker Bee, project , project advanced settings, network callback hook
Server install git
It has been installed here, just to view.
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
adds the pub
public key to the personal settings of Tencent Worker Bee
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.
Then enter Jenkins through the server's public network address, set the initial password, install the recommended plug-in, and enter the main page.
Download the tapd Jenkins plug-in,
enter the Jenkins system management, plug-in management, advanced, upload the plug-in
Configure the global tapd plug-in ( picture from the Tapd document )
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 management
- 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
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,
configure the settings.xml
path installed by maven,
Git, Node, Maven and other configurations are similar
Create Jenkins Job
Because here is a maven project, you need to install Maven Integration
plug-ins.
Associate tapd, fill in the tapd project id
parameter setting in the project , and the time is arbitrary.
Fill in the address of Tencent worker bee warehouse.
Add the previously generated ssh key to
maven project construction in Credentials. You
can choose to build the trigger or not
The command executed after the build is completed.
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