Merge "Support "All Strategies Match" and "Any Strategies Match""

This commit is contained in:
Zuul 2020-11-03 15:52:45 +00:00 committed by Gerrit Code Review
commit 63dbc6752e
9 changed files with 129 additions and 2 deletions

View File

@ -1107,6 +1107,12 @@ def build_strategies(xml_parent, data):
:arg list build-strategies: Definition of build strategies. :arg list build-strategies: Definition of build strategies.
* **all-strategies-match** (dict): All sub strategies must match for
this strategy to match.
* **strategies** (list): Sub strategies
* **any-strategies-match** (dict): Builds whenever any of the sub
strategies match.
* **strategies** (list): Sub strategies
* **tags** (dict): Builds tags * **tags** (dict): Builds tags
* **ignore-tags-newer-than** (int) The number of days since the tag * **ignore-tags-newer-than** (int) The number of days since the tag
was created before it is eligible for automatic building. was created before it is eligible for automatic building.
@ -1151,8 +1157,29 @@ def build_strategies(xml_parent, data):
""" """
basic_build_strategies = "jenkins.branch.buildstrategies.basic" basic_build_strategies = "jenkins.branch.buildstrategies.basic"
if data.get("build-strategies", None):
bbs_data = data.get("build-strategies", None)
bbs = XML.SubElement(xml_parent, "buildStrategies") bbs = XML.SubElement(xml_parent, "buildStrategies")
for bbs_list in data.get("build-strategies", None): else:
bbs_data = data.get("strategies", None)
bbs = XML.SubElement(xml_parent, "strategies")
for bbs_list in bbs_data:
if "all-strategies-match" in bbs_list:
all_elem = XML.SubElement(
bbs,
"".join([basic_build_strategies, ".AllBranchBuildStrategyImpl"]),
{"plugin": "basic-branch-build-strategies"},
)
build_strategies(all_elem, bbs_list["all-strategies-match"])
if "any-strategies-match" in bbs_list:
any_elem = XML.SubElement(
bbs,
"".join([basic_build_strategies, ".AnyBranchBuildStrategyImpl"]),
{"plugin": "basic-branch-build-strategies"},
)
build_strategies(any_elem, bbs_list["any-strategies-match"])
if "tags" in bbs_list: if "tags" in bbs_list:
tags = bbs_list["tags"] tags = bbs_list["tags"]
tags_elem = XML.SubElement( tags_elem = XML.SubElement(

View File

@ -134,6 +134,23 @@
</properties> </properties>
</strategy> </strategy>
<buildStrategies> <buildStrategies>
<jenkins.branch.buildstrategies.basic.AllBranchBuildStrategyImpl plugin="basic-branch-build-strategies">
<strategies>
<jenkins.branch.buildstrategies.basic.BranchBuildStrategyImpl plugin="basic-branch-build-strategies"/>
<jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing plugin="basic-branch-build-strategies"/>
</strategies>
</jenkins.branch.buildstrategies.basic.AllBranchBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.AnyBranchBuildStrategyImpl plugin="basic-branch-build-strategies">
<strategies>
<jenkins.branch.buildstrategies.basic.ChangeRequestBuildStrategyImpl plugin="basic-branch-build-strategies">
<ignoreTargetOnlyChanges>false</ignoreTargetOnlyChanges>
</jenkins.branch.buildstrategies.basic.ChangeRequestBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies">
<atMostMillis>-1</atMostMillis>
<atLeastMillis>-1</atLeastMillis>
</jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl>
</strategies>
</jenkins.branch.buildstrategies.basic.AnyBranchBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies"> <jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies">
<atMostMillis>86400000</atMostMillis> <atMostMillis>86400000</atMostMillis>
<atLeastMillis>604800000</atLeastMillis> <atLeastMillis>604800000</atLeastMillis>

View File

@ -28,6 +28,14 @@ scm:
- '+refs/heads/*:refs/remotes/@{remote}/*' - '+refs/heads/*:refs/remotes/@{remote}/*'
- '+refs/tags/*:refs/remotes/@{remote}/*' - '+refs/tags/*:refs/remotes/@{remote}/*'
build-strategies: build-strategies:
- all-strategies-match:
strategies:
- regular-branches: true
- skip-initial-build: true
- any-strategies-match:
strategies:
- change-request: {}
- tags: {}
- tags: - tags:
ignore-tags-newer-than: 1 ignore-tags-newer-than: 1
ignore-tags-older-than: 7 ignore-tags-older-than: 7

View File

@ -64,6 +64,23 @@
</properties> </properties>
</strategy> </strategy>
<buildStrategies> <buildStrategies>
<jenkins.branch.buildstrategies.basic.AllBranchBuildStrategyImpl plugin="basic-branch-build-strategies">
<strategies>
<jenkins.branch.buildstrategies.basic.BranchBuildStrategyImpl plugin="basic-branch-build-strategies"/>
<jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing plugin="basic-branch-build-strategies"/>
</strategies>
</jenkins.branch.buildstrategies.basic.AllBranchBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.AnyBranchBuildStrategyImpl plugin="basic-branch-build-strategies">
<strategies>
<jenkins.branch.buildstrategies.basic.ChangeRequestBuildStrategyImpl plugin="basic-branch-build-strategies">
<ignoreTargetOnlyChanges>false</ignoreTargetOnlyChanges>
</jenkins.branch.buildstrategies.basic.ChangeRequestBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies">
<atMostMillis>-1</atMostMillis>
<atLeastMillis>-1</atLeastMillis>
</jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl>
</strategies>
</jenkins.branch.buildstrategies.basic.AnyBranchBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies"> <jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies">
<atMostMillis>86400000</atMostMillis> <atMostMillis>86400000</atMostMillis>
<atLeastMillis>604800000</atLeastMillis> <atLeastMillis>604800000</atLeastMillis>

View File

@ -15,6 +15,14 @@ scm:
query-operator: 'SCHEME' query-operator: 'SCHEME'
query-string: 'jenkins' query-string: 'jenkins'
build-strategies: build-strategies:
- all-strategies-match:
strategies:
- regular-branches: true
- skip-initial-build: true
- any-strategies-match:
strategies:
- change-request: {}
- tags: {}
- tags: - tags:
ignore-tags-newer-than: 1 ignore-tags-newer-than: 1
ignore-tags-older-than: 7 ignore-tags-older-than: 7

View File

@ -92,6 +92,23 @@
</properties> </properties>
</strategy> </strategy>
<buildStrategies> <buildStrategies>
<jenkins.branch.buildstrategies.basic.AllBranchBuildStrategyImpl plugin="basic-branch-build-strategies">
<strategies>
<jenkins.branch.buildstrategies.basic.BranchBuildStrategyImpl plugin="basic-branch-build-strategies"/>
<jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing plugin="basic-branch-build-strategies"/>
</strategies>
</jenkins.branch.buildstrategies.basic.AllBranchBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.AnyBranchBuildStrategyImpl plugin="basic-branch-build-strategies">
<strategies>
<jenkins.branch.buildstrategies.basic.ChangeRequestBuildStrategyImpl plugin="basic-branch-build-strategies">
<ignoreTargetOnlyChanges>false</ignoreTargetOnlyChanges>
</jenkins.branch.buildstrategies.basic.ChangeRequestBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies">
<atMostMillis>-1</atMostMillis>
<atLeastMillis>-1</atLeastMillis>
</jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl>
</strategies>
</jenkins.branch.buildstrategies.basic.AnyBranchBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies"> <jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies">
<atMostMillis>86400000</atMostMillis> <atMostMillis>86400000</atMostMillis>
<atLeastMillis>604800000</atLeastMillis> <atLeastMillis>604800000</atLeastMillis>

View File

@ -14,6 +14,14 @@ scm:
- suppress-scm-triggering: true - suppress-scm-triggering: true
- pipeline-branch-durability-override: max-survivability - pipeline-branch-durability-override: max-survivability
build-strategies: build-strategies:
- all-strategies-match:
strategies:
- regular-branches: true
- skip-initial-build: true
- any-strategies-match:
strategies:
- change-request: {}
- tags: {}
- tags: - tags:
ignore-tags-newer-than: 1 ignore-tags-newer-than: 1
ignore-tags-older-than: 7 ignore-tags-older-than: 7

View File

@ -122,6 +122,23 @@
</properties> </properties>
</strategy> </strategy>
<buildStrategies> <buildStrategies>
<jenkins.branch.buildstrategies.basic.AllBranchBuildStrategyImpl plugin="basic-branch-build-strategies">
<strategies>
<jenkins.branch.buildstrategies.basic.BranchBuildStrategyImpl plugin="basic-branch-build-strategies"/>
<jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing plugin="basic-branch-build-strategies"/>
</strategies>
</jenkins.branch.buildstrategies.basic.AllBranchBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.AnyBranchBuildStrategyImpl plugin="basic-branch-build-strategies">
<strategies>
<jenkins.branch.buildstrategies.basic.ChangeRequestBuildStrategyImpl plugin="basic-branch-build-strategies">
<ignoreTargetOnlyChanges>false</ignoreTargetOnlyChanges>
</jenkins.branch.buildstrategies.basic.ChangeRequestBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies">
<atMostMillis>-1</atMostMillis>
<atLeastMillis>-1</atLeastMillis>
</jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl>
</strategies>
</jenkins.branch.buildstrategies.basic.AnyBranchBuildStrategyImpl>
<jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies"> <jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl plugin="basic-branch-build-strategies">
<atMostMillis>86400000</atMostMillis> <atMostMillis>86400000</atMostMillis>
<atLeastMillis>604800000</atLeastMillis> <atLeastMillis>604800000</atLeastMillis>

View File

@ -24,6 +24,14 @@ scm:
- trigger-build-on-pr-review: true - trigger-build-on-pr-review: true
- trigger-build-on-pr-update: true - trigger-build-on-pr-update: true
build-strategies: build-strategies:
- all-strategies-match:
strategies:
- regular-branches: true
- skip-initial-build: true
- any-strategies-match:
strategies:
- change-request: {}
- tags: {}
- tags: - tags:
ignore-tags-newer-than: 1 ignore-tags-newer-than: 1
ignore-tags-older-than: 7 ignore-tags-older-than: 7