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


    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
    
    • 1
    • 2

    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
    
    • 1
    • 2
    • 3

    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
    
    • 1
    • 2
    • 3

    上述过程执行完毕,最终以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"
    
    • 1

    2.2 Jenkins关联

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

    生成的id_rsa放到Jenkins中

    在这里插入图片描述

    2.3 WebHook

    首先去System配置关联

    在这里插入图片描述
    这里的需要配置API令牌,记得自己存一份,后续配置webhook会用到
    在这里插入图片描述
    在流水线中选择Generic Webhook Trigger

    在这里插入图片描述

    这里填入刚才生成API的时候得到的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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
  • 相关阅读:
    编译原理 LR(0)
    Molecular Psychiatry:神经成像预测模型在心理健康领域的未来趋势
    ResNet
    Ubuntu 下C++数字雨
    那些你不得不知道的CSS知识点
    夏季太热 MacBook 如何监控CPU温度和风扇转速?如何判断风扇是否工作?
    「Spring」认证安全架构指南
    2022 CLion 中的Cygwin 配置(最全,最良心版)
    牛客刷题总结——Python入门:输入输出、字符串、类型转换
    JAVA实现兔子问题--递归
  • 原文地址:https://blog.csdn.net/weixin_42763696/article/details/134499518