目录
1.如何拿到上一次jenkinsfile文件进行自动触发流水线
一、理论
1.HTTP请求
(1)概念
bash
HTTP超文本传输协议,是确保服务器(Server)和客户端(Client)之间的正确通信。
(2)响应过程
bash
1)Request 用户通过浏览器向我们的服务端发起请求。
请求: 客户端 ➡ 服务端
2)Response服务端将客户端请求的资源数据进行响应。
响应: 客户端 ⬅ 服务端
一个请求和响应的过程:

2.调用接口的方法
(1)请求类型
bash
1)GET 向指定的URL请求资源,可携带参数(明文)。
2)POST 向指定的URL提交资源,表单数据提交,数据进行封装(比Get方法安全)。
3)PUT 与POST类似,通常用于对资源数据的更新修改。
4)DELETE 删除指定的资源。
3.HTTP常见错误码
(1)错误码
bash
1xx : 服务已收到请求,请求者继续执行操作
2xx:请求成功,常见(201)
3xx:请求成功,页面发生重定向(301)
4xx:客户端发生了错误
常见的是资源找不到了(404)
资源请求需要认证认证失败(401)
认证成功但是权限不够(403)
5xx: 服务端发生了错误
网关超时(504)
内部错误(500)
网关错误(502)
服务不可用(503)
二、实验
1.Jenkins通过API触发流水线
(1)postman新建组(day3-apitest)

(2)安装插件

(3)新建文件夹

(4)保存

(5)新建流水线

(6)构建触发器与指定token

(7)保存

(8)postman点击触发

(9)jenkins已触发.

(10)构建成功

(11)可以生成python代码.
(12)生成curl代码

(13)主机复制curl代码

(14)jenkins生成第二次构建

(15)构建成功
(16)postman点击duplicate复制

(17)postman新增body的raw的josn键值对格式

(18)现在也能触发

(19)已触发,但是jenkins并没有消化数据

(20)修改postman的body,列表里嵌套字典

(21)构建触发器,获取2个变量(第一个变量获取第一层的字典,第二个变量获取数组里的字典

(22)开启打印日志功能

(23)编写流水线

(24)postman点击发送

(25)输出成功
(26)修改流水线

(27)postman点击发送

(28)构建成功

(29)postman添加header

(30)jenkins添加header变量

(31)修改流水线打印账户密码

(32)postman点击发送

(33)成功输出

(34)添加Request变量

(35)修改流水线代码

(36)postman添加变量

(37)postman发送

(38)构建成功
三、问题
1.如何拿到上一次jenkinsfile文件进行自动触发流水线
(1)解决方法
①安装rebuilder插件

②新增rebuild按钮
③点击rebuild

④成功
⑤成功拿到上一次jenkinsfile文件
