I have a Jenkins job that uses MultiScm to clone 2 git repositories. During polling, I want it to ignore one of the 2 repos. I can set "Polling ignores commits in certain paths" manually in the configuration to make that work (using ".*" as path to exclude).
I want to enable this through job-dsl as the job is created trhough it; however, I can't find the config that has changed. The job's config.xml is identical with or without the "Polling ignores..." setting.
Any idea on how to enable this through job-dsl?
The Job DSL plugin provides a solution, and allows you to configure Jenkins jobs as code. In this tutorial, you'll use Job DSL to configure two demo jobs: one that prints a 'Hello World' message in the console, and one that runs a pipeline from a Git repository.
Can You Use Jenkins With GitHub? You can and should use Jenkins with GitHub to save time and keep your project up-to-date. One of the basic steps of implementing CI/CD is integrating your SCM (Source Control Management) tool with your CI tool. This saves you time and keeps your project updated all the time.
Rundeck provides SCM Export and SCM Import providers for Git. This plugin allows Source Code Management of the jobs, versioning, exporting or importing their definitions using a remote Git repository.
When I add the "Polling ignores commits in certain paths" behaviour, the following elements are added to the config XML:
<project>
...
<scm class="org.jenkinsci.plugins.multiplescms.MultiSCM" plugin="[email protected]">
<scms>
<hudson.plugins.git.GitSCM plugin="[email protected]">
...
<extensions>
<hudson.plugins.git.extensions.impl.PathRestriction>
<includedRegions>foo</includedRegions>
<excludedRegions>bar</excludedRegions>
</hudson.plugins.git.extensions.impl.PathRestriction>
</extensions>
</hudson.plugins.git.GitSCM>
</scms>
...
</scm>
...
</project>
You can use the a Configure Block within the git context to add this config:
job('example') {
multiscm {
git {
remote {
github('jenkins/job-dsl-plugin')
}
configure { gitScm ->
gitScm / 'extensions' << 'hudson.plugins.git.extensions.impl.PathRestriction' {
includedRegions('foo')
excludedRegions('bar')
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With