jenkins dsl to gerritTrigger based on change in filepath

74 Views Asked by At

Team,

i have below working for triggering builds when user sets in comment test in gerrit gui reply. but I need to know how could i trigger if there is a change in path.

    triggers {
         gerrit customUrl: '',
         gerritProjects: [[
                           branches: [[compareType: 'PLAIN', pattern: 'main']],
                           compareType: 'PLAIN',
                           disableStrictForbiddenFileVerification: false,
                           pattern: 'product'
                         ]],
         serverName: 'gerrit.test.com',
         triggerOnEvents: [commentAddedContains('^test')]
    }

any hint how can i trigger if there is a change in file under this path? src/code/test

example: user pushes a new file or modifies a file under src/code/test/newfile.yaml or src/code/test/old.yaml I want to trigger build.

1

There are 1 best solutions below

0
Marcelo Ávila de Oliveira On

In the "gerritProjects" section, use the "filePaths" clause like in the following example:

filePaths: [[ compareType: 'ANT', pattern: "src/code/test/**" ]]

And change the "triggerOnEvents" clause to:

triggerOnEvents: [[
                    $class              : 'PluginPatchsetCreatedEvent',
                    excludeDrafts       : true,
                    excludeTrivialRebase: false,
                    excludeNoCodeChange : false
                  ]],