当前位置:金屋文档› 记录一次较为完整的Jenkins发布流程

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

文章标签:: java 运维 jenkins 开发语言
文章摘要: 如果要修改端口号,参考https://blog.csdn.net/Lifereunion/article/details/123430619。估计都是用Jenkins源下载的吧,官方打包的人脑子有吭,如果直接安装rpm包就不会这样。参考https://blog.csdn.net/BThinker/article/details/124178670。,否则jenkins默认会在构建完成后杀掉构建过程中又jenkins中shell命令触发的衍生进程。生成的id_rsa.pub放到github的配置中。

文章目录

    • 1. Jenkins安装
      • 1.1 Jenkins Docker安装
      • 1.2 Jenkins apt-get install安装
    • 2. 关联github/gitee服务与webhook
      • 2.1 配置ssh
      • 2.2 Jenkins关联
      • 2.3 WebHook
    • 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 updatesudo apt-get install fontconfig openjdk-17-jresudo 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=dontKillMepwdls -lrsh ./kill5050.shnpm installnpm install forever -gforever start server.js
相关文档
  • 完整

  • 流程

  • 较为

相关文档推荐: