当前位置:网站首页>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、测试
提交代码
边栏推荐
- Biotin-LC-Hydrazide|CAS:109276-34-8|生物素-LC-酰肼
- MySQL Workbench 安装及使用
- 科技云报道:实现元宇宙,英伟达从打造基础建设平台开始
- What is the function of the import command of the page directive in JSP?
- 为什么都推荐使用wordpress, 而不是 phpcms 这些国内的CMS呢?
- Detailed explanation of calculation commands in shell (expr, (()), $[], let, bc )
- Stop mental exhaustion Daily sharing
- ip地址那点事(二)
- EPSANet: An Efficient Pyramid Split Attention Block on Convolutional Neural Network
- 积分商城商品供应商选择的三个要求
猜你喜欢
随机推荐
知识点滴 - 为什么一般不用铜锅做菜
Gorilla Mux 和 GORM 的使用方法
PyQt5(一) PyQt5安装及配置,从文件夹读取图片并显示,模拟生成素描图像
构建Flink第一个应用程序
文章解读 -- FlowNet3D:Learning Scene Flow in 3D Point Clouds
Biotin-C6-amine|N-生物素基-1,6-己二胺|CAS:65953-56-2
pnpm:简介
Biotin-EDA|CAS:111790-37-5| 乙二胺生物素
Figure robot software digital twin station oil and gas pipelines, oil and gas transportation control platform
Ansible 学习总结(11)—— task 并行执行之 forks 与 serial 参数详解
Biotin-LC-Hydrazide|CAS:109276-34-8|生物素-LC-酰肼
Seleniu screenshots code and assign name to the picture
血气方刚的年轻小伙竟去做家政小哥,是怎样成功逆袭转行的
C语言基础_结构体
“蔚来杯“2022牛客暑期多校训练营4
The custom table form
JSP页面中page指令contentPage/pageEncoding具有什么功能呢?
USACO美国信息学奥赛竞赛12月份开赛,中国学生备赛指南
积分商城商品供应商选择的三个要求
(Note)阿克西斯ACASIS DT-3608双盘位硬盘阵列盒RAID设置








