任务需求:代码提交到gitlab时,触发Jenkins构建项目到docker容器中运行
步骤1 Jenkins
1.1 新建任务
qt_saas_erp_test
qt_saas_mes_test
1.2 修改配置
源码管理
Repositories
Repository URL:http://10.82.1.200/qt-saas/qt-saas.git
Credentials:选择有效证明
Branches to build
指定分支(为空时代表any):*/dev
1.3 触发构造器
选择
Build when a change is pushed to GitLab. GitLab webhook URL: http://10.210.2.51:90/project/qt_saas_erp_test
勾选:
Push Events
Opened Merge Request Events
Approved Merge Requests (EE-only)
Comments
点击高级选项
勾选:
Enable [ci-skip]
Ignore WIP Merge Requests
Set build description to build cause (eg. Merge request or Git Push)
Allowed branches
选择:
Filter branches by regex
在Source Branch Regex填写框写入设置的分支名字
text
注意:此时写入的test表示在提交代码到test分支的时候才会执行Jenkins构建项目到docker容器中
1.4 增加构建步骤
1.4.1 调用顶层Maven目标
Maven版本:
maven3.8.5
目标:
clean package -pl service/erp-service -am -Dmaven.test.skip=true
1.4.2 send files or execute commands over SSH
1.4.2.1 SSH Publishers
SSH Server
Name
10.82.1.201
1.4.2.2 Transfers
Transfer Set
Sourcefiles
service/erp-service/target/*.jar
注意:此处写入的是带前缀的jar包名
Remove prefix