Ignore triggering multibranch build for excluded regions

163 views
Skip to first unread message

Melo Vi

unread,
Dec 21, 2021, 10:31:45 PM12/21/21
to Jenkins Users
Hi all,

I am working with a multibranch pipeline in a config.yaml building a code repo pulled from Git.

I would like to not trigger a build if the code change falls within a certain set of files. The Job-DSL API Viewer seems to indicate that multibranchPipelineJob lacks this support out of the box?

I have configured the Multibranch build strategy extension through the Jenkins configure user interface and the committed files matching the filter are successfully ignored by the periodic build trigger. (attached)


However I would like to add this to my config.yaml so the change persists.

A snippet of config.xml after configuring the above in the UI looks as such:
```
        <buildStrategies>
          <com.igalg.jenkins.plugins.multibranch.buildstrategy.ExcludeRegionBranchBuildStrategy plugin="multibranch-build-...@1.0.10">
            <excludedRegions>**/*.py</excludedRegions>
          </com.igalg.jenkins.plugins.multibranch.buildstrategy.ExcludeRegionBranchBuildStrategy>
        </buildStrategies>
```

However I am unsure how this maps to an entry in config.yaml.

In config.yaml I have tried adding the following code block under Git

```
configure { node ->
                                node / 'buildStrategies' / 'com.igalg.jenkins.plugins.multibranch.buildstrategy.ExcludeRegionBranchBuildStrategy' {
                                    excludedRegions '**/*.py'
                                }
                            }
```

however this does not seem to work either.

Has anyone found a workable CasC solution to ignore triggering a build for certain specified excluded regions? 
multibranch-build-strategy-extension-plugin.png

Melo Vi

unread,
Feb 14, 2022, 10:19:21 PM2/14/22
to Jenkins Users

Solved this by using:


        multibranchPipelineJob('Foo') {
            branchSources {
                branchSource {
                    source {
                        git {
                            id('420')
                            credentialsId('Bar')
                            remote("g...@bitbucket.org:foo/foobar.git")
                        }
                    }
                    buildStrategies {
                        excludeRegionBranchBuildStrategy {
                            excludedRegions('foo/bar/**/*')
Reply all
Reply to author
Forward
0 new messages