Skip to content

Jenkins 安装笔记

安装

  1. jenkins.io 获取最新的 war 包,并启动。

    bash
    java -jar jenkins.war

    也可以自定义端口。

    bash
    java -jar D:\jenkins\jenkins.war --ajp13Port=-1 --httpPort=8090

    第一次启动会显示如下信息,这段字符就是初始的密码,初次访问网站时会用到。

    3d468549b7774496840b77ba21da24dc
    解锁 jenkins
    为了确保管理员安全地安装 jenkins,密码已写入到日志中(不知道在哪里?)该文件在服务器上:C:\Users\liujiajia\.jenkins\secrets\initialAdminPassword

  2. 打开 http://localhost:8080/,输入上面的密码,开始安装。

  3. 新建一个【构建一个自由风格的软件项目】的任务。

    也可以直接从已经创建好的任务复制。

  4. 设置源码管理(我这里使用的是 SVN)

    • Repository URL:SVN 代码目录所在的 URL
    • Credentials:可以点击旁边的 Add 按钮,输入用户名和密码;
    • 其它默认
  5. 构建触发器

    • 选择Poll SCM,并在日程表中输入如下内容(表示每分钟检查一次 SVN)(注意中间的空格不可以少)

      txt
      * * * * *

      修改为每三分钟检查一次

      txt
      */3 * * * *
  6. 构建

    • 新增一个【Invoke top-level Maven targets】步骤
      • Goals:输入mvn的命令,如:package
      • POM:pom.xml,如果 pom.xml 文件在子目录,可以按照【projectname/pom.xml】格式输入;
      • 其它默认
  7. 构建后操作

    可以通过使用钉钉的插件,自动发送通知;或者发送邮件等等。

上传打包后的文件到 FTP 服务器

  1. 安装【Publish Over FTP】插件

  2. 在【系统管理=>系统设置】中的【Publish over FTP】部分设置 FTP 上传的地址、用户密码等

  3. 在任务的【构建】中增加一个【Send files over FTP

    • FTP Server
      • Name:选择在系统设置中增加的 FTP 配置
      • Transfers
        • Source files
          • 需要上传的文件路径或者文件夹路径(相对于 workspace 下的该任务所在目录);
          • 可以使用通配符(*);
        • Remove prefix
          • 如果为空的话,上传到 FTP 后的目录结构同在 workspace 中的目录结构一致;
          • 如果设置的话,必须同 Source files 中设置的前面部分一致;
        • Remote directory:上传到 FTP 的目录;

重启 Windows Service

  • 增加构建步骤【Execute Windows batch command】,输入如下命令

    bash
    sc \\192.168.0.1 stop "ServiceName"
    
    ping 127.0.0.1 -n 20 >nul
    
    sc \\192.168.0.1 start "ServiceName"

发送钉钉通知

  1. 安装【Dingding[钉钉] Plugin】插件

  2. 在钉钉的群中添加机器人,并记下【webhook】值

    http
    https://oapi.dingtalk.com/robot/send?access_token=d9050d9515ceb115ee86edfc1111d5859737679bb111c8c7b0335e069d927df
  3. 在【构建后操作】中新增【钉钉通知器配置】步骤

    • jenkins URL:本地 Jenkins 的地址,在钉钉中点击推送的消息会跳转到该地址;

    • 钉钉access token:输入上面【webhook】中的【access_token】的值;

    • 后面的【在启动构建时通知】【构建成功时通知】【构建失败时通知】根据需求勾选;

参考文档

  1. 使用 Jenkins 进行持续集成
  2. Jenkins 修改端口号(成功率高)
  3. jenkins 集成钉钉机器人
  4. Jenkins 用户组管理
  5. 自定义钉钉机器人

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.