记录一次较为完整的Jenkins发布流程

文章目录

    • [1. Jenkins安装](#1. Jenkins安装)
      • [1.1 Jenkins Docker安装](#1.1 Jenkins Docker安装)
      • [1.2 Jenkins apt-get install安装](#1.2 Jenkins apt-get install安装)
    • [2. 关联github/gitee服务与webhook](#2. 关联github/gitee服务与webhook)
      • [2.1 配置ssh](#2.1 配置ssh)
      • [2.2 Jenkins关联](#2.2 Jenkins关联)
      • [2.3 WebHook](#2.3 WebHook)
    • [3. 前后端关联发布](#3. 前后端关联发布)

1. Jenkins安装

1.1 Jenkins Docker安装

Docker很好,但是我没有玩明白如何使用Docker的jenkins发布服务。因此仅做个记录

参考https://juejin.cn/post/7219899306946199610

这篇文章详细讲述了Docker中Jenkins如果想启其他docker服务的过程,值得参考
参考https://blog.csdn.net/BThinker/article/details/124178670

这篇文章详细讲述了Jenkins Docker的安装过程,值得参考

1.2 Jenkins apt-get install安装

直接参考官网https://pkg.jenkins.io/debian-stable/

This is the Debian package repository of Jenkins to automate installation and upgrade. To use this repository, first add the key to your system (for the Weekly Release Line):

复制代码
  sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
    https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key

Then add a Jenkins apt repository entry:

复制代码
  echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
    https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
    /etc/apt/sources.list.d/jenkins.list > /dev/null

Update your local package index, then finally install Jenkins:

复制代码
sudo apt-get update
sudo apt-get install fontconfig openjdk-17-jre
sudo apt-get install jenkins

上述过程执行完毕,最终以systemctl的方式启动

如果要修改端口号,参考https://blog.csdn.net/Lifereunion/article/details/123430619

需要用systemctl status jenkins找到配置文件,然后直接在配置文件修改

借用评论区老哥的一句话

把配置写在服务里,这就离谱。。。估计都是用Jenkins源下载的吧,官方打包的人脑子有吭,如果直接安装rpm包就不会这样。

2. 关联github/gitee服务与webhook

参考 https://www.jianshu.com/p/dca1ec8187aa。写得很好

2.1 配置ssh

gitee和github流程差不多,都是本地

复制代码
ssh-keygen -t rsa -C "your_email@example.com"

2.2 Jenkins关联

生成的id_rsa.pub放到github的配置中

生成的id_rsa放到Jenkins中

2.3 WebHook

首先去System配置关联

这里的需要配置API令牌,记得自己存一份,以后就看不到这个API令牌了

在流水线中选择Generic Webhook Trigger

这里通过该网站https://chahuo.com/token-generator.html随机生成一段token

按照上述url在gitee部分也进行同样设置

3. 前后端关联发布

参考https://www.cnblogs.com/gaojinshun/p/15273011.html

我用的是shell的方式发布服务

注意一定需要加入BUILD_ID=dontKillMe,否则jenkins默认会在构建完成后杀掉构建过程中又jenkins中shell命令触发的衍生进程。

复制代码
BUILD_ID=dontKillMe

pwd
ls -lr
sh ./kill5050.sh

npm install
npm install forever -g
forever start server.js
相关推荐
江畔柳前堤13 小时前
github实战指南01-账号配置与 SSH 密钥
运维·人工智能·深度学习·ssh·github·pyqt·信号处理
Moshow郑锴15 小时前
Ubuntu 26.04 中文输入法 : fcitx5+Rime中州韵引擎
linux·运维·ubuntu
小赖同学啊17 小时前
智能连接器集群化高可用生产方案
linux·运维·人工智能
wanghao66645517 小时前
DevOps 从入门到实践:构建高效交付流水线
运维·devops
qq_5469372717 小时前
从“能用”到“超神”,DeepSeek++给网页版装上“大脑”和“手脚”,支持长期记忆、MCP工具与自动化任务!
运维·自动化
ZStack开发者社区17 小时前
基于AI Agent的ZCF API文档全链路自动化
运维·人工智能·自动化
Moshow郑锴18 小时前
Ubuntu 26.04 更换阿里云源镜像
linux·运维·ubuntu
迷糊小面包19 小时前
Docker Hadopp集群版部署搭建及常规问题解疑
运维·docker·容器
ShineWinsu19 小时前
对于Linux:线程概念与分页存储管理的解析
linux·运维·服务器·面试·线程·进程·虚拟空间地址
器灵科技19 小时前
AI视频工具实测:Seedance/可灵/HappyHorse谁最能打?
java·运维·数据库·人工智能·github