当前位置:网站首页>Jenkins--部署--3.1--代码提交自动触发jenkins--方式1
Jenkins--部署--3.1--代码提交自动触发jenkins--方式1
2022-08-02 08:22:00 【单身贵族男】
Jenkins–部署–3.1–代码提交自动触发jenkins–方式1
1、介绍
使用 Generic Webhook Trigger方式
2、配置
2.1、创建流水线任务
autoPush
脚本内容
pipeline {
//运行在任意的可用节点上
agent any
stages {
stage('阶段1') {
steps("步骤名称:拉取代码"){
echo '打印:拉取代码'
}
}
}
}
2.2、配置触发器
2.3、gitlab 配置钩子
2.4、测试
提交代码后
3、配置匹配规则
3.1、输出的请求参数
{
"object_kind": "push",
"event_name": "push",
"before": "d70bf1526bf3290df712fc63c40d371857e36685",
"after": "67f35f0361f320fb35aa7079447778e3aec24aab",
"ref": "refs/heads/master",
"checkout_sha": "67f35f0361f320fb35aa7079447778e3aec24aab",
"message": null,
"user_id": 2,
"user_name": "zhoufei",
"user_username": "zhoufei",
"user_email": "[email protected]",
"user_avatar": "https://www.gravatar.com/avatar/83c56c2ac027851091a829ad08992525?s=80&d=identicon",
"project_id": 2,
"project": {
"id": 2,
"name": "user_manager",
"description": "用户管理",
"web_url": "http://gitlab.xgss.net/user_search/user_manager",
"avatar_url": null,
"git_ssh_url": "[email protected]:user_search/user_manager.git",
"git_http_url": "http://gitlab.xgss.net/user_search/user_manager.git",
"namespace": "user_search",
"visibility_level": 0,
"path_with_namespace": "user_search/user_manager",
"default_branch": "master",
"ci_config_path": null,
"homepage": "http://gitlab.xgss.net/user_search/user_manager",
"url": "[email protected]:user_search/user_manager.git",
"ssh_url": "[email protected]:user_search/user_manager.git",
"http_url": "http://gitlab.xgss.net/user_search/user_manager.git"
},
"commits": [
{
"id": "67f35f0361f320fb35aa7079447778e3aec24aab",
"message": "init\n",
"timestamp": "2022-07-23T12:32:10Z",
"url": "http://gitlab.xgss.net/user_search/user_manager/commit/67f35f0361f320fb35aa7079447778e3aec24aab",
"author": {
"name": "zhoufei",
"email": "[email protected]"
},
"added": [
"readme25.md"
],
"modified": [],
"removed": []
}
],
"total_commits_count": 1,
"repository": {
"name": "user_manager",
"url": "[email protected]:user_search/user_manager.git",
"description": "用户管理",
"homepage": "http://gitlab.xgss.net/user_search/user_manager",
"git_http_url": "http://gitlab.xgss.net/user_search/user_manager.git",
"git_ssh_url": "[email protected]:user_search/user_manager.git",
"visibility_level": 0
}
}
3.2、匹配参数语法
3.2.1、取值语法
- $开头表示:是一个变量
- .表示:根节点
- $key,如果取出的value还是json那么则以点为分隔符继续写key的名字
3.2.2、举例
# 取出 "user_name": "zhoufei" 这一行中的value
.user_name
# 取出 "name": "user_manager" 这一行中的value
.project.name
3.3、配置匹配参数
3.3.1、匹配参数
ref
$.ref
project_name
$.project.name
新增一个变量
再新增一个变量
3.3.2、匹配规则
refs/heads/master_user_manager
$ref_$project_name
- Expression:写匹配规则,支持正则
- Text:要匹配的文本内容
- KaTeX parse error: Expected group after '_' at position 4: ref_̲project_name:对应内容是refs/heads/master_user_manager,也就是Expression要匹配的内容
- 只有匹配成功,才回走流水线脚本
4、测试
提交代码
边栏推荐
- Ansible learning summary (11) - detailed explanation of forks and serial parameters of task parallel execution
- BGP solves routing black hole through MPLS
- (Note)阿克西斯ACASIS DT-3608双盘位硬盘阵列盒RAID设置
- etcd implements large-scale service governance application combat
- postman使用方法
- HCIP笔记第十三天
- Biotin-C6-amine|N-生物素基-1,6-己二胺|CAS:65953-56-2
- JSP中page指令的import命令具有什么功能呢?
- 二分类和多分类
- Gorilla Mux 和 GORM 的使用方法
猜你喜欢
随机推荐
Business Intelligence Platform BI Business Intelligence Analysis Platform How to Choose the Right Business Intelligence Platform BI
PyCharm使用教程(较详细,图+文)
ip地址那点事(二)
Docker内MySQL主从复制学习,以及遇到的一些问题
Hikari连接池源码解读
(Note) AXIS ACASIS DT-3608 Dual-bay Hard Disk Array Box RAID Setting
RetinaFace: Single-stage Dense Face Localisation in the Wild
构建Flink第一个应用程序
pnpm的安装与使用
next permutation
mysqldump --set-gtid-purged=OFF
JSP页面中page指令contentPage/pageEncoding具有什么功能呢?
mysql 中 in 的用法
Button to control the running water light (timer)
UVM之sequence机制
Pycharm (1) the basic use of tutorial
了解下C# 多线程
按键控制流水灯(计时器)
C语言_指针
What attributes and methods are available for page directives in JSP pages?