当前位置:网站首页>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、测试
提交代码
边栏推荐
- C语言_指针
- 力扣:第 304 场周赛
- Redisson distributed lock source code analysis for high-level use of redis
- Axial Turbine Privacy Policy
- Redis分布式锁
- Biotinyl Cystamine|CAS:128915-82-2|生物素半胱胺
- A little bit of knowledge - why do not usually cook with copper pots
- 查看变量的数据格式
- 软件测试技术之解析图灵测试离我们还有多远
- 商业智能平台BI 商业智能分析平台 如何选择合适的商业智能平台BI
猜你喜欢
随机推荐
OneNote 教程,如何在 OneNote 中创建更多空间?
mysql 中 in 的用法
如何建立私域流量?私域流量对企业有什么好处?
cas: 139504-50-0 Maytansine DM1|Mertansine|
积分商城商品供应商选择的三个要求
uvm-phase机制
[ansible] playbook explains the execution steps in combination with the project
【论文阅读】Distilling the Knowledge in a Neural Network
C语言基础_结构体
知识点滴 - 为什么一般不用铜锅做菜
Database triggers and transactions
Codeforces Round #811 (Div. 3)无DF
prometheus monitoring mysql_galera cluster
OneNote Tutorial, How to Create More Spaces in OneNote?
Application and case analysis of CASA model and CENTURY model
【C】关于柔性数组.简要的谈谈柔性数组
PostgreSQL学习总结(11)—— PostgreSQL 常用的高可用集群方案
下一个排列
R语言plotly可视化:使用plotly可视化模型预测真阳性率(True positive)TPR和假阳性率(False positive)FPR在不同阈值(threshold)下的曲线
Flink 程序剖析









