jenkins一键推送到远程服务器并用docker容器启动

news2024/9/21 16:23:04

1.安装jenkins

我后端使用的是宝塔面板来安装的容器化jenkins,要选中允许外部访问,安装完之后没有那个选项了,一开始安装的时候要选中不使用域名和后面的允许外部访问。Jenkins 版本为: 2.462.1
Jenkins版本

2.配置Jenkins

2.1 Git plugin

安装完毕之后可以在项目构建的之后直接从gitee中拉取代码,不过需要先配置全局凭证,我这边使用的是账户密码。

代码拉取

2.2Maven Integration plugin

安装完毕之后可以构建maven项目。
构建maven项目

2.3Publish Over SSH

安装之后可以将代码推送到远程服务器,首先保存全局凭证,此处我使用的还是账号密码,然后再system下配置Publish Over SSH。之后点击下方测试查看是否可以正常连接。
Publish Over SSH配置
然后在项目构建中,Post Steps下面添加生成后的步骤,"通过SSH发送文件或执行命令"选项, 然后添加如下配置:
步骤配置
服务器是上面配置的。
源文件:定义为:**/*,不过为了不必要的传输改为 **/ruoyi-admin.jar
删除前缀:是根据打包后文件所在路径来进行删除,不然会把目录也推送到远程服务器。
远程目录:远程目录为空时,默认使用上面服务器配置的路径
Exec 命令:在远程服务器上执行的命令

3. 构建记录和访问结果

channel stopped
SSH: Connecting from host [d4ea9e4c162f]
SSH: Connecting with configuration [one day server] ...
SSH: Creating session: username [root], hostname [154.64.000.102], port [22]
SSH: Connecting session ...
SSH: Connected
SSH: Opening SFTP channel ...
SSH: SFTP channel open
SSH: Connecting SFTP channel ...
SSH: Connected
SSH: cd [/develop/ruoyi/]
SSH: OK
SSH: cd [/develop/ruoyi/]
SSH: OK
SSH: put [ruoyi-admin.jar]
SSH: Opening exec channel ...
SSH: EXEC: channel open
SSH: EXEC: STDOUT/STDERR from command [cd /develop/ruoyi/

nohup java -jar ruoyi-admin.jar] ...
SSH: EXEC: connected
Application Version: 4.7.9
Spring Boot Version: 2.5.15

//                          _ooOoo_                               //
//                         o8888888o                              //
//                         88" . "88                              //
//                         (| ^_^ |)                              //
//                         O\  =  /O                              //
//                      ____/`---'\____                           //
//                    .'  \\|     |//  `.                         //
//                   /  \\|||  :  |||//  \                        //
//                  /  _||||| -:- |||||-  \                       //
//                  |   | \\\  -  /// |   |                       //
//                  | \_|  ''\---/''  |   |                       //
//                  \  .-\__  `-`  ___/-. /                       //
//                ___`. .'  /--.--\  `. . ___                     //
//              ."" '<  `.___\_<|>_/___.'  >'"".                  //
//            | | :  `- \`.;`\ _ /`;.`/ - ` : | |                 //
//            \  \ `-.   \_ __\ /__ _/   .-` /  /                 //
//      ========`-.____`-.___\_____/___.-`____.-'========         //
//                           `=---='                              //
//      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        //
//             佛祖保佑       永不宕机      永无BUG               //

11:32:16.142 [main] INFO  c.r.RuoYiApplication - [logStarting,55] - Starting RuoYiApplication using Java 1.8.0_362 on instance-6obVdquJ with PID 332642 (/develop/ruoyi/ruoyi-admin.jar started by root in /develop/ruoyi)
11:32:16.161 [main] DEBUG c.r.RuoYiApplication - [logStarting,56] - Running with Spring Boot v2.5.15, Spring v5.3.33
11:32:16.162 [main] INFO  c.r.RuoYiApplication - [logStartupProfileInfo,686] - The following 1 profile is active: "druid"
11:32:16.166 [background-preinit] INFO  o.h.v.i.util.Version - [<clinit>,21] - HV000001: Hibernate Validator 6.2.5.Final
11:32:19.002 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-authCache]
11:32:20.217 [main] INFO  c.a.d.p.DruidDataSource - [init,1002] - {dataSource-1} inited
11:32:21.523 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [loginRecordCache]
11:32:21.620 [main] DEBUG c.r.s.m.S.selectConfigList - [debug,135] - ==>  Preparing: select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark from sys_config
11:32:21.860 [main] DEBUG c.r.s.m.S.selectConfigList - [debug,135] - ==> Parameters: 
11:32:21.894 [main] DEBUG c.r.s.m.S.selectConfigList - [debug,135] - <==      Total: 11
11:32:21.901 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-config]
11:32:21.906 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-config]
11:32:21.907 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-config]
11:32:21.907 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-config]
11:32:21.908 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-config]
11:32:21.909 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-config]
11:32:21.909 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-config]
11:32:21.910 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-config]
11:32:21.911 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-config]
11:32:21.912 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-config]
11:32:21.912 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-config]
11:32:22.539 [main] DEBUG c.r.s.m.S.selectDictDataList - [debug,135] - ==>  Preparing: select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark from sys_dict_data WHERE status = ?
11:32:22.550 [main] DEBUG c.r.s.m.S.selectDictDataList - [debug,135] - ==> Parameters: 0(String)
11:32:22.573 [main] DEBUG c.r.s.m.S.selectDictDataList - [debug,135] - <==      Total: 29
11:32:22.577 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-dict]
11:32:22.579 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-dict]
11:32:22.579 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-dict]
11:32:22.580 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-dict]
11:32:22.581 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-dict]
11:32:22.582 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-dict]
11:32:22.582 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-dict]
11:32:22.583 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-dict]
11:32:22.583 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-dict]
11:32:22.585 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-dict]
11:32:22.851 [main] INFO  o.q.i.StdSchedulerFactory - [instantiate,1220] - Using default implementation for ThreadExecutor
11:32:22.878 [main] INFO  o.q.c.SchedulerSignalerImpl - [<init>,61] - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
11:32:22.879 [main] INFO  o.q.c.QuartzScheduler - [<init>,229] - Quartz Scheduler v.2.3.2 created.
11:32:22.880 [main] INFO  o.q.s.RAMJobStore - [initialize,155] - RAMJobStore initialized.
11:32:22.881 [main] INFO  o.q.c.QuartzScheduler - [initialize,294] - Scheduler meta-data: Quartz Scheduler (v2.3.2) 'quartzScheduler' with instanceId 'NON_CLUSTERED'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.

11:32:22.882 [main] INFO  o.q.i.StdSchedulerFactory - [instantiate,1374] - Quartz scheduler 'quartzScheduler' initialized from an externally provided properties instance.
11:32:22.882 [main] INFO  o.q.i.StdSchedulerFactory - [instantiate,1378] - Quartz scheduler version: 2.3.2
11:32:22.883 [main] INFO  o.q.c.QuartzScheduler - [setJobFactory,2293] - JobFactory set to: org.springframework.scheduling.quartz.SpringBeanJobFactory@14fc1f0
11:32:22.950 [main] DEBUG c.r.q.m.S.selectJobAll - [debug,135] - ==>  Preparing: select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark from sys_job
11:32:22.952 [main] DEBUG c.r.q.m.S.selectJobAll - [debug,135] - ==> Parameters: 
11:32:22.957 [main] DEBUG c.r.q.m.S.selectJobAll - [debug,135] - <==      Total: 3
11:32:23.374 [main] INFO  o.a.s.c.e.EhCacheManager - [getCache,169] - Using existing EHCache named [sys-userCache]
11:32:23.704 [main] INFO  o.a.c.h.Http11NioProtocol - [log,173] - Initializing ProtocolHandler ["http-nio-80"]
11:32:23.704 [main] INFO  o.a.c.c.StandardService - [log,173] - Starting service [Tomcat]
11:32:23.705 [main] INFO  o.a.c.c.StandardEngine - [log,173] - Starting Servlet engine: [Apache Tomcat/9.0.75]
11:32:23.778 [main] INFO  o.a.c.c.C.[.[.[/] - [log,173] - Initializing Spring embedded WebApplicationContext
11:32:26.083 [main] INFO  o.a.c.h.Http11NioProtocol - [log,173] - Starting ProtocolHandler ["http-nio-80"]
11:32:26.741 [main] INFO  o.q.c.QuartzScheduler - [start,547] - Scheduler quartzScheduler_$_NON_CLUSTERED started.
11:32:26.754 [main] INFO  c.r.RuoYiApplication - [logStarted,61] - Started RuoYiApplication in 11.293 seconds (JVM running for 12.178)
(♥◠‿◠)ノ゙  若依启动成功   ლ(´ڡ`)゙  
 .-------.       ____     __        
 |  _ _   \      \   \   /  /    
 | ( ' )  |       \  _. /  '       
 |(_ o _) /        _( )_ .'         
 | (_,_).' __  ___(_ o _)'          
 |  |\ \  |  ||   |(_,_)'         
 |  | \ `'   /|   `-'  /           
 |  |  \    /  \      /           
 ''-'   `'-'    `-..-'              

在这里插入图片描述

4.使用docker启动项目

保证远程服务器已经安装docker,然后将下面的命令放到exce命令里面

# 打开文件发送到的路径
cd /develop/ruoyi/
# 停止容器ruoyi
docker stop ruoyi
# 删除容器ruoyi
docker rm ruoyi
# 删除标签为admin-image的镜像(应该是,需要测试)
docker rmi -f admin-image
# 根据dockerfile创建新的标签为admin-image的镜像。
# 后面的.代表执行dockerfile,dockerfile和ruoyi-admin.jar在同级目录下
docker build -t admin-image .
# 后台启动容器,容器名称为ruoyi,对外暴露端口号80
# -d为后台启动
docker run -d --name ruoyi -p 80:80 admin-image

下面是dockerfile:

# 基础镜像
FROM  openjdk:8-jre
# 挂载目录
VOLUME /home/ruoyi
# 创建目录
RUN mkdir -p /home/ruoyi
# 指定路径
WORKDIR /home/ruoyi
# 设置时区为上海
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone
# 复制jar文件到路径
COPY ./ruoyi-admin.jar /home/ruoyi/ruoyi-admin.jar
# 启动系统服务
ENTRYPOINT ["java","-Xms125m","-Xmx125m","-jar","ruoyi-admin.jar"]

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2033099.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

江新安教授受邀引正基因进行《制药行业研发项目管理》培训

近日&#xff0c;科济管线创始人江新安教授应赛柏蓝邀请为北京引正基因科技有限公司&#xff08;简称引正基因&#xff09;进行《研发项目管理》授课。为提高项目管理水平&#xff0c;加强研发项目相关人员的管理能力&#xff0c;掌握研发项目管理技能与工具&#xff0c;江新安…

AI招聘在人才盘活中的作用:开启智慧人力新篇章

一、引言&#xff1a;AI赋能招聘新纪元 在21世纪的今天&#xff0c;随着科技的飞速发展&#xff0c;人工智能&#xff08;AI&#xff09;已经渗透到社会经济的各个角落&#xff0c;其中&#xff0c;人力资源管理领域也不例外。AI技术的引入&#xff0c;不仅颠覆了传统的招聘模…

代码规范 —— QMQ 开发规范

优质博文&#xff1a;IT-BLOG-CN 一、代码规范 【1】消费者必须以Consumer结尾&#xff0c;生产者必须以Producer结尾。 【2】选择合适的消费模式&#xff1a;根据业务判断消费模式是集群模式还是广播模式&#xff0c;具体为&#xff1a;MessageConsumerProvider.addListene…

R的行和列命名和类型的转换

下面内容摘录自&#xff1a; 4章8节&#xff1a;用R做数据重塑&#xff0c;行列命名和数据类型转换-CSDN博客 欢迎订阅我们专栏 一、行和列命名 在数据科学和统计分析中&#xff0c;命名是组织和管理数据的一个重要部分。尤其是在处理复杂的多维数据集时&#xff0c;为行和列命…

FPGA知识基础之--FIFO ip核的使用以及实例化clocking wizard ip产生一个异步FIFO,附RTL和仿真代码

目录 一、FIFO简介1.定义2.特点3.分类4.FIFO在FPGA中的应用 二、实验任务三、FIFO IP核1.接口2.写时序3.读时序1.Standara2 .FWFT 四、vivado设置五、程序设计1.模块2.时序3.异步信号传输4.RTL代码 五、仿真1.Testbench代码2.波形 一、FIFO简介 1.定义 FIFO是一种先进先出的数…

电能表在企业能源管理中的作用

电能表在企业能源管理中扮演着至关重要的角色&#xff0c;它不仅是能源计量的基础工具&#xff0c;更是企业实现高效能源管理、降低能源成本、提高竞争力的关键所在。 一、精确计量与实时监测 电能表作为能源计量的基础工具&#xff0c;其首要作用是实现电能的精确计量。相比…

PostgreSQL 练习 ---- psql 新增连接参数

目标 添加一个连接参数&#xff0c;默认为 false 。当 psql 连接时&#xff0c;若该连接参数非 “true” 时&#xff0c;用户 “u1“ 对表对象无操作权限&#xff0c;包括自己拥有的表。 连接机制简介 连接过程如下所述&#xff1a; 客户端初始化一个空连接&#xff0c;设置…

如何高效记录并整理编程学习笔记?

一&#xff1a;简介 在编程学习的过程中&#xff0c;建立一个高效的笔记记录和整理方法确实非常重要。下面是一些方法和建议&#xff0c;帮助你打造自己的编程学习“知识宝库”。 1&#xff09;. 选择合适的工具 选择一个适合自己的笔记工具非常重要。可以考虑以下几种&#…

SB3045LFCT-ASEMI无人机专用SB3045LFCT

编辑&#xff1a;ll SB3045LFCT-ASEMI无人机专用SB3045LFCT 型号&#xff1a;SB3045LFCT 品牌&#xff1a;ASEMI 封装&#xff1a;TO-220F 批号&#xff1a;最新 最大平均正向电流&#xff08;IF&#xff09;&#xff1a;30A 最大循环峰值反向电压&#xff08;VRRM&…

大模型系列8-Latex

大模型系列8-Latex 背景Latex符号符号加帽子、横线和波浪线求和连乘希腊字母等于约等于积分微分公式对齐算法矩阵 背景 目前正通过论文、博客、视频、文档等各种形式学习各种大模型知识。为了更好的记录&#xff0c;写了一些大模型的博客&#xff0c;不专业&#xff0c;只备忘…

Openlayers6 图形绘制和修改功能(结合React)

Openlayers常用的API了解的差不多了&#xff0c;就开始进入实战了&#xff0c;首先从绘制基本的图形开始&#xff0c;这里主要介绍一下绘制圆形、矩形和多边形。 通过使用openlayers的ol.interaction.Draw和ol.interaction.Modify模块实现地图上绘制圆形、矩形、多边形并修改编…

2024.8.12(LVS)

一、LVS 1、描述以及工作原理 1. 什么是LVS linux virtural server的简称,也就是linxu虚拟机服务器,这是一个由章文嵩博士发起的开源项目,官网是http://www.linuxvirtualserver.org,现在lvs已经是linux内核标准的一部分,使用lvs可以达到的技术目标是:通过linux达到负载均衡技…

mysql注入-字符编码技巧

一、环境搭建 创建数据表 CREATE TABLE mysql_Bian_Man (id int(10) unsigned NOT NULL AUTO_INCREMENT,username varchar(255) COLLATE latin1_general_ci NOT NULL,password varchar(255) COLLATE latin1_general_ci NOT NULL,PRIMARY KEY (id) ) ENGINEMyISAM AUTO_INCREME…

Python办公自动化:使用`xlutils` 修改Excel文档

在日常办公自动化中&#xff0c;除了读取Excel文件&#xff0c;我们还经常需要对文件进行修改或更新。在Python中&#xff0c;除了xlrd&#xff0c;还可以使用xlutils库来实现对Excel文件的修改操作。本文将继续以“巴黎奥运会奖牌榜.xlsx”文件为例&#xff0c;讲解如何使用xl…

OpenCV + CUDA + cuDNN模块编译

简介 在追求高端性能与资源优化并重的应用场景中&#xff0c;如边缘计算设备或资源受限的开发板上运行YOLO等复杂深度学习模型&#xff0c;采用C结合OpenCV与GPU加速技术相较于传统的Python环境展现出显著优势。这种策略不仅极大地提升了执行效率&#xff0c;还显著降低了运行时…

陶晶池串口屏数据存储区概述与使用

陶晶池串口屏的数据存储区大小&#xff1a;x系列是2k字节的&#xff0c;其他系列是1k字节的&#xff0c;超出了就会从头覆盖最先的字节 你可以在主动解析模式下调用u[x]来访问数据存储区内第x-1字节是什么&#xff0c;也可以读取usize看看记录大小 它的原理是&#xff0c;每接收…

axios 封装避免重复请求(两种)

目录 前言 Demo 第一种实现方法 第二种方法&#xff08;axios版本0.22.0以上&#xff09; 前言 在当今的前端开发领域&#xff0c;数据交互是不可或缺的一环。Axios 作为一款基于 Promise 的 HTTP 客户端&#xff0c;因其简洁的 API 和丰富的配置选项&#xff0c;深受广大…

R语言的下载和安装

R是一种强大的编程语言和环境&#xff0c;主要用于统计计算和数据分析。自从R诞生以来&#xff0c;它在统计学家和数据科学家中迅速普及。然而&#xff0c;R本身只是一个命令行工具&#xff0c;对于大多数用户来说&#xff0c;单独使用R可能会有些困难或者不方便。RStudio作为一…

科技云报道:“大模型+机器人”,具身智能将开启“智械时代”

科技云报道原创。 从15世纪达芬奇绘制出世界上第一份人形机器人手稿&#xff0c;到如今波士顿动力、本田、特斯拉、Figure AI等企业相继推出了人形机器人产品&#xff0c;机器人新物种持续衍生&#xff0c;人形机器人产业已经从萌芽概念阶段进入产业化落地前期。 近日&#x…

Golang面试题四(并发编程)

目录 1.Go常见的并发模型 2.哪些方法安全读写共享变量 3.如何排查数据竞争问题 ​4.Go有哪些同步原语 1. Mutex (互斥锁) 2. RWMutex (读写互斥锁) 3. Atomic 3.1.使用场景 3.2.整型操作 3.3.指针操作 3.4.使用示例 4. Channel 使用场景 使用示例 5. sync.WaitGr…