简体   繁体   English

使用 Gerrit 触发器启动 Jenkins 管道 - 正则表达式

[英]Starting Jenkins pipeline with Gerrit trigger - regular expression

I need to trigger a Jenkins build pipeline for N projects.我需要为 N 个项目触发 Jenkins 构建管道。 These are stored in a Gerrit and their names have a pattern like this:这些存储在 Gerrit 中,它们的名称具有如下模式:

MODEL_A, MODEL_B, MODEL_C, etc.

So, in my opinion the best would be to use a regular expression for the comparison:因此,在我看来,最好的方法是使用正则表达式进行比较:

pipeline
    ...
    triggers {
        gerrit(
                gerritProjects: [[
                compareType: 'REG_EXP',
                pattern : '**/MODEL_[A|B|C]**',
                branches : [[
                    compareType: 'REG_EXP',
                    pattern : '**'
                ]]
            ]],
            triggerOnEvents: [[
                $class : 'PluginPatchsetCreatedEvent',
                excludeDrafts : false,
                excludeTrivialRebase: false,
                excludeNoCodeChange : false
            ]]
        )
    }
    ...
}

The problem is that, no matter where I do the commit, no project is built.问题是,无论我在哪里提交,都没有构建项目。 The patter is not a PCRE compliant patternand on the offigial Jenkis Gerrit trigger page is no example for such case.该模式不是符合 PCRE 的模式,并且在官方 Jenkis Gerrit 触发页面上不是这种情况的示例。

Any hint with this regex?这个正则表达式有什么提示吗?

Change from:更改自:

pattern : '**/MODEL_[A|B|C]**'

To:至:

pattern : '.*\/MODEL_[A-C].*'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM