docker入门 3:jenkins集成github
2021-02-18 本文已影响0人
SwiftBirds
基本原理
- 本地代码push到Github
- webhook检测到Github的push事件
- 触发Jenkins进行一次build
- 自动化部署完成
配置步骤
1、Github生成Personal Access Token
- Github –>Settings –> Developer settings –> Personal access tokens –> Generate new token

- 勾选如下图所示权限,最后点击 generate token 生成令牌

2、设置Jenkins的Github Server配置
- Manage Jenkins –> Configure System --> 找到 GitHub 选项 –> 添加 Github 服务器 –> GitHub Server

- 点击add添加凭证,将Personal Access Token填入

- Github具体需要持续集成的项目 -> 点击Settings -> 点击Webhooks,将webhook填入


3、Jenkins Job项目配置Trigger
- 任意新建一个Freestyle project 配置如下

- 设置Build Triggers

4、构建脚本
- 填写shell脚本

- 添加运行变量

Manage Jenkins –> Configure System --> 找到 Global properties 选项,添加环境变量
