0

Gerrit Trigger 2.32.0

I configuration "Trigger on" with "Ref Updated" to support push event.But I find when I reply on the pathset with comment, Ref Updated is triggered. Param GERRIT_REFNAME is refs/changes/96/996/meta. I don't know how to filtered it to make only push event triggered by "Ref Updated" event.

JainPing
  • 75
  • 1
  • 7

1 Answers1

0

You can use a regular expression to filter out refs you're not interested in. The REG_EXP comparison type seems to use Java's Pattern, which supports negative lookaheads.

Example expression which doesn't match anything that starts with "refs/": ^(?!refs/).*$.

Full example for trigger setup (using a scripted pipeline):

properties([
        pipelineTriggers([
                [
                        $class         : 'GerritTrigger',
                        gerritProjects : [
                                [
                                        $class     : 'GerritProject',
                                        compareType: 'PLAIN',
                                        pattern    : 'my-gerrit-project',
                                        branches   : [
                                                [
                                                        $class     : 'Branch',
                                                        compareType: 'REG_EXP',
                                                        // does not start with "refs/"
                                                        pattern    : '^(?!refs/).*$'
                                                ]
                                        ]
                                ]
                        ],
                        triggerOnEvents: [
                                [
                                        $class: 'PluginPatchsetCreatedEvent'
                                ],
                                [
                                        $class: 'PluginRefUpdatedEvent'
                                ]
                        ]
                ]
        ])
])

(I know this is more than 2 years late, but I just ran into this issue, so maybe it helps someone.)