jenkins 使用 maven 方式部署 shop-boot java 工程

这篇博客介绍了如何使用jenkins结合maven部署shop-boot java工程。首先,配置jenkins插件源和权限策略,然后进行git ssh多用户配置,包括密钥管理和权限设置。接着,手动部署gitee上的spring boot项目,包括创建项目、编写启动脚本和实现ssh免密远程启动。最后,简述了maven项目的配置流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

基础配置

jenkins 插件源修改

进入/home/devops/.jenkins/updates目录

[devops@devops updates]$ pwd
/home/devops/.jenkins/updates
[devops@devops updates]$ ls
default.json  hudson.tasks.Maven.MavenInstaller
[devops@devops updates]$ 

执行

sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json

进入jenkins的插件管理,病设置Update Site,网址为:

https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json

重启tomcat生效

汉化插件

在这里插入图片描述

Role-based Authorization Strategy 插件

此插件暂未启用
在这里插入图片描述

凭据插件

在这里插入图片描述
进入凭据配置页面【有些版本首页没有凭据菜单,可以手动输入地址进入】
在这里插入图片描述

gitee 插件

帮助文档: https://gitee.com/help/articles/4193

git ssh 多用户配置

将来有可能使用gitlab

删除全局git用户信息

多用户情况下,尽量不要设置全局用户信息

# 添加全局用户信息
git config --global user.name "用户名"
git config --global user.email "邮箱"
#删除全局用户信息
git config --global --unset user.name
git config --global --unset user.email

生成 key

$ ssh-keygen -t rsa -C "github@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): id_rsa_github
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa_github.
Your public key has been saved in id_rsa_github.pub.
The key fingerprint is:
SHA256:K8ZzHA4rrhgHlv7qyP+dAmvpQIq+jPUpbMdjXZncAnE github@qq.com
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|      . E        |
|       o         |
|  .   .          |
|.+    .oS+       |
|*. . . =*o.      |
|++o.=.*.=.       |
|*=**==o+.        |
|=OBO=o.o         |
+----[SHA256]-----+

使用同样的方式生成另一个Key,并将key添加至相应网站

配置 config

文件位置 ~/.ssh/config [注意不可有注释]

Host gitee.com
    User sanren2016
    Hostname gitee.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_gitee

将密匙加入密匙管理器

$ ssh-agent bash
$ ssh-add ~/.ssh/id_rsa_github
Enter passphrase for /c/Users/Administrator/.ssh/id_rsa_github:
Identity added: /c/Users/Administrator/.ssh/id_rsa_github (/c/Users/Administrator/.ssh/id_rsa_github)
 
$ ssh-add ~/.ssh/id_rsa_gitlab
Enter passphrase for /c/Users/Administrator/.ssh/id_rsa_gitlab:

Bad owner or permissions on .ssh/config的解决

chmod 600 config

克隆后的操作

git config user.name "xxx"
git config user.email "xxx"

手动部署项目

gitee 新建项目

https://gitee.com/sanren2016/shop-boot

添加一个简单接口,参见:https://gitee.com/sanren2016/shop-boot/commit/ce3771c208b3fbaaa2f577d78ff9669279457dc1

spring boot 脚本启动

启动脚本与配置文件

  • 目录结构
[stest@shopboot shop-boot]$ pwd
/home/stest/shop-boot
[stest@shopboot shop-boot]$ tree
.
├── conf
│   ├── application.yml
│   └── logback-spring.xml
├── logs
├── sbin
│   └── control.sh
└── shop-boot.jar

3
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值