Support for filtering repositories in GitHub Organizations

Change-Id: I7758cf89bbaac6942bb7d8fc697f83b1b6466637
This commit is contained in:
Stephen Boyd 2024-04-29 15:07:52 -07:00
parent 137586d548
commit 7acc23a1f5
No known key found for this signature in database
GPG Key ID: 276674E18F6FBD22
3 changed files with 15 additions and 0 deletions

View File

@ -206,6 +206,9 @@ def github_org(xml_parent, data):
first be configured in Global Configuration. (default GitHub)
:arg str branch-discovery: Discovers branches on the repository.
Valid options: no-pr, only-pr, all, false. (default 'no-pr')
:arg str repo-name-regex: Regular expression used to match repository names
within the organization. (optional)
Requires the :jenkins-plugins:`SCM API plugin <scm-api>`.
:arg list build-strategies: Provides control over whether to build a branch
(or branch like things such as change requests and tags) whenever it is
discovered initially or a change from the previous revision has been
@ -384,6 +387,14 @@ def github_org(xml_parent, data):
rshf = XML.SubElement(traits, "jenkins.scm.impl.trait.RegexSCMHeadFilterTrait")
XML.SubElement(rshf, "regex").text = data.get("head-filter-regex")
if data.get("repo-name-regex", None):
rssf = XML.SubElement(
traits,
"jenkins.scm.impl.trait.RegexSCMSourceFilterTrait",
{"plugin": "scm-api"},
)
XML.SubElement(rssf, "regex").text = data.get("repo-name-regex")
if data.get("head-pr-filter-behaviors", None):
multibranch.add_filter_branch_pr_behaviors(
traits, data.get("head-pr-filter-behaviors")

View File

@ -41,6 +41,9 @@
<jenkins.scm.impl.trait.RegexSCMHeadFilterTrait>
<regex>(.*/master|.*/release/.*)</regex>
</jenkins.scm.impl.trait.RegexSCMHeadFilterTrait>
<jenkins.scm.impl.trait.RegexSCMSourceFilterTrait plugin="scm-api">
<regex>example-repo-name|fancy-regex*</regex>
</jenkins.scm.impl.trait.RegexSCMSourceFilterTrait>
<net.gleske.scmfilter.impl.trait.RegexSCMHeadFilterTrait plugin="scm-filter-branch-pr">
<regex>foo/.*</regex>
<tagRegex>20\..*</tagRegex>

View File

@ -7,6 +7,7 @@ github-org:
repo-owner: example-owner
credentials-id: example-credential
branch-discovery: all
repo-name-regex: "example-repo-name|fancy-regex*"
head-filter-regex: "(.*/master|.*/release/.*)"
head-pr-filter-behaviors:
head-pr-destined-regex: