0、下载apache-maven,复制到服务器,并且解压(tar zxvf apache-maven-3.9.9-bin.tar.gz)到/usr/local/maven。https://maven.apache.org/download.cgi
1、安装插件Maven Integration
2、安装git apt install git

3、配置maven目录(全局)

4、设置item。
1,源码管理,设置git地址http://192.168.100.26/code/fine.git
2,设置全局的密码
3,设置指定分支Branches to build,*/main

5、安装插件 publish over ssh

6、Post Steps 步骤选择《Run regardless of build result》,再次选择Send files or execute commands over SSH

7、全局配置 Manage Jenkins-》System-》Publish over SSH,注意勾选高级,填写密码

8、填写Source files : **/.jar;填写Remote directory:/xxoo;Exec command:nohup java -jar /root/xxoo/main/target/main.jar >mylog.log 2>&1 &

9、安装插件 Build Authorization Token Root 匿名构建项目
http://192.168.100.127:8080/buildByToken/build?job=first&token=123123

10、打开gitlab,在管理员里面
设置-》网络-》出站请求-》勾选 “允许来自 webhooks 和集成对本地网络的请求”
11、项目库-》设置-》Webhooks 添加,URL 添加http://192.168.100.127:8080/buildByToken/build?job=first&token=123123
然后,勾选出发来源。取消SSL验证。点击保存。

Screenshot_2025-05-03_08-47-58