一、安装配置Jenkins1.1 安装Jenkins和插件1.2 内网穿透1.3 其他引用二、基于 Jenkins+ Gitee/Gitlab/Gitee搭建CI/CD环境2.1 建立FreeStyle任务2.1.1 去除历史编译设置2.1.2 源码管理配置2.1.3 构建触发器2.1.4 编译步骤2.2 构建流水任务2.2.1 Jenkisn 配置2.2.2 Gitee 配置三、 引入cppcheck实现静态检测四、引入脚本+htmlreport+email实现单元测试4.1 邮箱通知引用
一、安装配置Jenkins
1.1 安装Jenkins和插件
Windows 安装 Windows (jenkins.io)
- 0x8007052e -Error logging on,操作后使用系统用户名和密码登录
- Java: see the Java Requirements page
Supported Java versions | Long term support (LTS) release | Weekly release |
Java 11, Java 17, or Java 21 | 2.426.1 (November 2023) | 2.419 (August 2023) |
Java 11 or Java 17 | 2.361.1 (September 2022) | 2.357 (June 2022) |
Java 8, Java 11, or Java 17 | 2.346.1 (June 2022) | 2.340 (March 2022) |
Java 8 or Java 11 | 2.164.1 (March 2019) | 2.164 (February 2019) |
- Web browser: see the Web Browser Compatibility page
- For Windows operating system: Windows Support Policy
- For Linux operating system: Linux Support Policy
- For servlet containers: Servlet Container Support Policy
树莓派/Ubuntu 安装jenkins 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):
- Then add a Jenkins apt repository entry:
- Update your local package index, then finally install Jenkins:
安装 gitee 插件
1.2 内网穿透
参考 该文如何在树莓派上使用Nginx搭建本地站点并通过内网穿透实现远程访问 - cpolar 极点云官网,安装coplar并搭建隧道(连接到jenkins8080端口),实现内网穿透访问。
要注意的是,以上步骤使用的是随机临时地址,该公网地址24小时内会随机变化。我们接下来为其配置固定地址,该地址不会变化,设置后将无需每天重复修改地址。因此需升级至基础套餐或以上才支持配置固定域名。
- Dashboard | Manage Jenkins |System

- Dashboard | STP-RTOS | Configuration

1.3 其他
- git服务器 GitLab服务器搭建/gitee/github
- 安装 git
- 安装 cmake
引用
Jenkins 重启方法
方法一:通过 Jenkins Web 界面
- 打开 Web 浏览器,并导航至 Jenkins 的网址,例如
http://localhost:8080
(如果 Jenkins 正在本地运行)。
- 登录到 Jenkins 控制台。
- 点击右上角的用户名,然后选择 "Manage Jenkins"。
- 在左侧导航栏中,选择 "Manage Nodes and Clouds"。
- 在节点列表中,找到 "Master" 节点(通常是默认的),点击它。
- 在节点详情页面,点击左侧的 "Disconnect"(断开连接)按钮,然后再点击 "Connect"(连接),这会重启 Jenkins 服务。
方法二:通过 Jenkins 命令行工具
- 打开命令提示符(cmd)或 PowerShell。
- 导航至 Jenkins 的安装目录。
- 运行以下命令来重启 Jenkins 服务:

二、基于 Jenkins+ Gitee/Gitlab/Gitee搭建CI/CD环境
2.1 建立FreeStyle任务
2.1.1 去除历史编译设置

2.1.2 源码管理配置

2.1.3 构建触发器

2.1.4 编译步骤
2.2 构建流水任务
2.2.1 Jenkisn 配置
- 选择流水线任务
- 创建任务
- 创建触发器(gitee webhook地址和密码在这里获取,gitee配置需要)


- 选择配置- 高级项目选项
- pipeline script
- 流水线语法
- 片段生成器
- checkout拉取代码(URL-用户名密码-选择分支)
- 生成流水线脚本
- 把脚本拷贝过来粘贴到这里
报错:No ECDSA host key is known for
打开 Manage jenkins --> Configure Global Security ,找到 Git Host Key Verification Configuration,按下图修改后保存。警告信息可以忽略


- 立即构建
- 控制台输出 console output
- 直接在脚本这里写上编译命令

- 立即构建

2.2.2 Gitee 配置
管理

问题1:webhook404
解决方法2:无需更改,只是gitee测试接口错误[2]