当前位置:网站首页>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、测试
提交代码
边栏推荐
- What attributes and methods are available for page directives in JSP pages?
- day_05 time 模块
- High imitation [Huawei consumer business official website] and wonderful animation analysis: practice embedding JS code in low-code platform
- A little bit of knowledge - why do not usually cook with copper pots
- Figure robot software digital twin station oil and gas pipelines, oil and gas transportation control platform
- “蔚来杯“2022牛客暑期多校训练营4
- 十大免费cms建站系统介绍推荐
- Shell变成规范与变量
- prometheus监控mysql_galera集群
- 高仿【华为消费者业务官网】和精彩动画剖析:练习在低代码平台中嵌入JS代码
猜你喜欢

工程师如何对待开源 --- 一个老工程师的肺腑之言

Write a small game in C (three chess)

Postman download localization of installation and use
![shell中计算命令详解(expr、(())、 $[]、let、bc )](/img/3c/5cc4d16b9b525997761445f32802d5.png)
shell中计算命令详解(expr、(())、 $[]、let、bc )

A young man with strong blood and energy actually became a housekeeper. How did he successfully turn around and change careers?

Figure robot software digital twin station oil and gas pipelines, oil and gas transportation control platform

pnpm: Introduction

王学岗-编译出运行的文件

Redis分布式锁入门

查看变量的数据格式
随机推荐
PyQt5(一) PyQt5安装及配置,从文件夹读取图片并显示,模拟生成素描图像
Redisson distributed lock source code analysis for high-level use of redis
小康股份更名赛力斯,如何走出一条高端产品的“丝绸之路”?
Redis分布式锁入门
C语言_指针
Shell变成规范与变量
Write a small game in C (three chess)
MySQL 中 count() 和 count(1) 有什么区别?哪个性能最好?
Redis分布式锁
查看变量的数据格式
PyCharm使用教程(详细版 - 图文结合)
IO进程线程->进程->day4
Biotin hydrazide HCl|CAS:66640-86-6|生物素-酰肼盐酸盐
postman使用方法
52. [Bool type input any non-0 value is not 1 version reason]
Technology Cloud Report: To realize the metaverse, NVIDIA starts from building an infrastructure platform
OneNote Tutorial, How to Create More Spaces in OneNote?
轴流式水轮机隐私政策
Spark 系统性学习笔记系列
Postman download localization of installation and use