diff --git a/jenkins_jobs/modules/project_multibranch.py b/jenkins_jobs/modules/project_multibranch.py index 166bed3c9..4a6e61f20 100644 --- a/jenkins_jobs/modules/project_multibranch.py +++ b/jenkins_jobs/modules/project_multibranch.py @@ -86,6 +86,7 @@ import six from jenkins_jobs.modules.scm import git_extensions from jenkins_jobs.errors import InvalidAttributeError from jenkins_jobs.errors import JenkinsJobsException +from jenkins_jobs.xml_config import remove_ignorable_whitespace logger = logging.getLogger(str(__name__)) @@ -1102,6 +1103,8 @@ def build_strategies(xml_parent, data): Requires the :jenkins-plugins:`Basic Branch Build Strategies Plugin `. + Other build strategies can be configured via raw XML injection. + :arg list build-strategies: Definition of build strategies. * **tags** (dict): Builds tags @@ -1142,6 +1145,8 @@ def build_strategies(xml_parent, data): for example: `master release*` (default `*`) * **excludes** (str) Name patterns to ignore even if matched by the includes list. For example: release (optional) + * **raw** (dict): Injects raw BuildStrategy XML to use other build + strategy plugins. """ @@ -1268,6 +1273,11 @@ def build_strategies(xml_parent, data): fail_required=False, ) + if "raw" in bbs_list: + raw_xml = XML.fromstring(bbs_list["raw"].get("xml")) + remove_ignorable_whitespace(raw_xml) + XML.SubElement(bbs, None).append(raw_xml) + def property_strategies(xml_parent, data): """Configure Basic Branch Property Strategies. diff --git a/tests/multibranch/fixtures/scm_git_full.xml b/tests/multibranch/fixtures/scm_git_full.xml index 77c4c435e..50ecbe9ed 100644 --- a/tests/multibranch/fixtures/scm_git_full.xml +++ b/tests/multibranch/fixtures/scm_git_full.xml @@ -140,6 +140,9 @@ + + my/cool/project/*.cpp + diff --git a/tests/multibranch/fixtures/scm_git_full.yaml b/tests/multibranch/fixtures/scm_git_full.yaml index 3454f5b04..dc52fbcba 100644 --- a/tests/multibranch/fixtures/scm_git_full.yaml +++ b/tests/multibranch/fixtures/scm_git_full.yaml @@ -37,6 +37,11 @@ scm: - exact-name: {} - regex-name: {} - wildcards-name: {} + - raw: + xml: | + + my/cool/project/*.cpp + clean: after: true before: true