Jenkins + github 自动化部署配置

1 Jenkins安装

AWS EC2安装Jenkins:AWS EC2 + JDK11 + Jenkins-CSDN博客

AWS EC2上Docker安装Jenkins:https://blog.csdn.net/hhujjj2005/article/details/139078402

2 登录jenkins

http://192.168.1.128:8080/

bash 复制代码
$ docker exec -it d1851d9e3386 /bin/bash
$ cat /var/jenkins_home/secrets/initialAdminPassword
c1495a8c95004561b66b04c09fb6231f

填入密码,继续,选择"安装推荐的插件",安装完成,创建第一个管理员用户root,填写密码,实例配置保持默认值

点击开始使用Jenkins

3 安装jenkins插件

  1. maven插件

Dashboard -> Manage Jenkins -> plugins -> Available plugins

4 jdk,maven,git配置

Dashboard -> Manage Jenkins -> Tools

  1. jdk配置
  1. git配置
  1. maven配置

5 凭据

添加两种类型的凭据,Username with password和Secret text(填的token)

Username with password是github登录的用户名和密码,Secret text填的github生成的token,权限的限制更细,安全性更高一些

Dashboard -> Manage Jenkins -> 凭据 -> 全局 -> Add Credentials

  1. Username with password
  1. Secret text

登录github生成token,Settings -> Developer Settings -> Personal access tokens (classic) -> Tokens(classic)

创建凭据,Secret填上面在github生成的token

6 配置github server

Dashboard -> 系统管理 -> System,下拉到Github

7 创建任务

  1. general
bash 复制代码
项目URL:https://github.com/JJJ2018/springboot_helloworld_example
Repository URL:https://github.com/JJJ2018/springboot_helloworld_example.git
  1. 源码管理

Credentials选Username with password凭证

  1. 构建触发器

勾选GitHub hook trigger for GITScm polling

勾选远程构建,填写身份验证令牌token

  1. 构建环境
  1. Build

8 GitHub webhook的URL

  1. JENKINS_API_TOKEN
bash 复制代码
GitHub webhook的URL格式:http://<JENKINS_USER>:<JENKINS_API_TOKEN>@<JENKINS_SERVER>/job/<JOB_NAME>/build?token=<TOKEN>

用的用户jiang生成的JENKINS_API_TOKEN,TOKEN是构建触发器中生成的123456
 

webhook:http://jiang:<JENKINS_API_TOKEN>@192.168.1.128:8080/job/springboot_task/build?token=123456
  1. github生成webhook

Payload URL填写webhook

绿√是安装成功,如果安装有问题再多检查了多试试

9 自动构建

提交代码到github会触发任务的自动构建

相关推荐
就叫飞六吧1 天前
Jenkins 流水线全流程实战笔记
笔记·servlet·jenkins
a努力。1 天前
中国电网Java面试被问:RPC序列化的协议升级和向后兼容
java·开发语言·elasticsearch·面试·职场和发展·rpc·jenkins
cly13 天前
Jenkins重置管理员密码
运维·servlet·jenkins
tianyuanwo3 天前
Jenkins Job管理实战指南:增删改查与批量操作技巧
运维·jenkins
Dxy12393102163 天前
Elasticsearch 8.13.4 地理范围查询实战指南
大数据·elasticsearch·jenkins
未定义.2213 天前
第7篇:跨端拓展!Playwright+Appium实现Web+移动端全覆盖
python·ui·appium·自动化·jenkins·pytest
Apex Predator4 天前
jenkins备份与恢复
运维·jenkins
屿小夏.4 天前
【Elasticsearch】Elasticsearch的分片和副本机制
大数据·elasticsearch·jenkins
柯南小海盗4 天前
Elasticsearch同义词配置全攻略
大数据·elasticsearch·jenkins
未定义.2214 天前
第5篇:进阶优化:数据驱动+日志体系+失败重试实战
python·ui·自动化·jenkins·集成测试·pytest