惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
有赞技术团队
有赞技术团队
量子位
N
Netflix TechBlog - Medium
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
GbyAI
GbyAI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
Martin Fowler
Martin Fowler
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
V
V2EX
IT之家
IT之家
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

mafeifan 的编程技术分享

mafengwo-mp3-downloader | mafeifan 的编程技术分享 示例页面 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 查看 default namespace 下的 default service account名称 mafeifan 的编程技术分享 检查日志 | mafeifan 的编程技术分享 bridge fdb show dev flannel.1 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享
mafeifan 的编程技术分享
2026-01-16 · via mafeifan 的编程技术分享

想实现合并代码后才触发Pipeline流水线构建,可以借助强大的 Generic Webhook Trigger 插件做到

流程 ​

  1. Build Triggers 下开启 Generic Webhook Trigger
  2. 配置全局唯一token
  3. 开启 Print post content 和 Print contributed variables in job log选项,可以看到接收到的payload和自定义变量
  4. gitlab或github配置merge request事件的webhook

5. 创建merge request,观察数据

合并后GitLab的webhook触发了, 我们需要对比开启请求和合并请求的数据。找不同,找特点。

# approved状态
$.event_type = merge_request
$.object_attributes.state = opened
$.object_attributes.action = approved

# merge状态
$.event_type = merge_request
$.object_attributes.state = merged
$.object_attributes.action = merge


#拿到source和target分支
$.object_attributes.source_branch
$.object_attributes.target_branch
  1. 此部分都是在jenkins上面配置的 配置Generic Webhook的过滤没用的请求,实现精准触发

groovy

currentBuild.description = "Trigger: ${source_branch}  > ${target_branch} \n${event_type}  \n ${state}  \n ${action}"

pipeline {
    agent any
    
    triggers {
        GenericTrigger(causeString: 'Generic Cause', 
            genericVariables: [[defaultValue: '', key: 'event_type', regexpFilter: '', value: '$.event_type'], 
                [defaultValue: 'NULL', key: 'state', regexpFilter: '', value: '$.object_attributes.state'], 
                [defaultValue: 'NULL', key: 'action', regexpFilter: '', value: '$.object_attributes.action'],
                [defaultValue: 'NULL', key: 'source_branch', regexpFilter: '', value: '$.object_attributes.source_branch'], 
                [defaultValue: 'NULL', key: 'target_branch', regexpFilter: '', value: '$.object_attributes.target_branch']],
            printContributedVariables: true, 
            printPostContent: true, 
            regexpFilterExpression: '^merge_request\\smerged\\smerge$', 
            regexpFilterText: '$event_type $state $action', 
            token: 'devops-merge-trigger', 
            tokenCredentialId: '')
    }

    stages {
        stage('Hello') {
            steps {
                echo 'Hello World'
            }
        }
    }
}
  1. 完成

参考 ​

https://mp.weixin.qq.com/s/VuM8EqKp448fama_qXkJvQ