'multibranchPipelineJob Job DSL: How to enable Filter by name (with wildcards)

How to enable in a Jenkins job DSL for a multibranch pipeline the behavior Filter by name (with wildcards). I tried it in following way but it didn't work.

configure { def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits traits << 'org.jenkinsci.plugins.github__branch__source.WildcardSCMHeadFilterTrait' { excludes("production") includes("*") } }



Solution 1:[1]

    traits << 'jenkins.scm.impl.trait.WildcardSCMHeadFilterTrait' {
        includes('master PR-*')
    }

worked for me to add the entry to behaviors.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jgsogo