Jenkins -仅为jenkins webhook触发器的失败或成功事件触发管道

i5desfxk  于 2023-11-17  发布在  Jenkins
关注(0)|答案(1)|浏览(206)

我想使用Jenkins webhook触发器触发一个管道,当接收到的事件失败或成功时,它只触发两种情况。enter image description here
例如:如果我有一个像下面这样的JSON事件日志

{"involvedObject":{"kind":"HelmRelease","namespace":"flux-system","name":"my-release","uid":"1f86243d-bcd9-4e0a-b078-c9df8f9441ac","apiVersion":"helm.toolkit.fluxcd.io/v2beta1","resourceVersion":"1466894"},"severity":"info","timestamp":"2023-10-25T06:20:18Z","message":"Helm upgrade succeeded","reason":"info","metadata":{"revision":"6.5.2"},"reportingController":"helm-controller","reportingInstance":"helm-controller-578bd944df-m9sgx"}

字符串
我希望此事件仅过滤使用regexp "Helm upgrade succeeded""Helm upgrade failed"的消息。如果任何其他过滤器与此消息分离,则不应触发我的管道。
任何对regexp的帮助都是很好的。|$success),(failed| success).. dint work**注意:**我正在使用Jenkins webhook Trigger插件用于上述用例,并在此插件下使用可选的过滤器。

57hvy0tb

57hvy0tb1#

安装通用webhook触发器插件并尝试一下

pipeline {
    agent any
    triggers {
        GenericTrigger(
               genericVariables: [
                       [key: 'payload', value: '$'],
                       [key: 'message', value: '$.message'],
               ],
               regexpFilterText: '$message',
               regexpFilterExpression: '(Helm upgrade succeeded)|(Helm upgrade failed)'
               causeString: 'Triggered by helm ', //give it any cause you want
               token: "<your-token>",
        )
    }

字符串

相关问题