diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index 59b6b1a96..aba77a934 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -554,16 +554,24 @@ def build_blocker(registry, xml_parent, data): :arg bool use-build-blocker: Enable or disable build blocker (default true) :arg list blocking-jobs: One regular expression per line to select - blocking jobs by their names. (required) + blocking jobs by their names (required) :arg str block-level: block build globally ('GLOBAL') or per node ('NODE') (default 'GLOBAL') :arg str queue-scanning: scan build queue for all builds ('ALL') or only - buildable builds ('BUILDABLE') (default 'DISABLED')) + buildable builds ('BUILDABLE') (default 'DISABLED') Example: + Minimal Example: + .. literalinclude:: - /../../tests/properties/fixtures/build-blocker01.yaml + /../../tests/properties/fixtures/build-blocker-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: + /../../tests/properties/fixtures/build-blocker-full.yaml :language: yaml """ blocker = XML.SubElement(xml_parent, @@ -575,14 +583,16 @@ def build_blocker(registry, xml_parent, data): raise JenkinsJobsException('blocking-jobs list must not be empty') jobs = '' - for value in data['blocking-jobs']: - jobs = jobs + value + '\n' + for setting, value in data.items(): + if setting == 'blocking-jobs': + jobs = '\n'.join(value) + block_level_types = ['GLOBAL', 'NODE'] + queue_scan_types = ['DISABLED', 'ALL', 'BUILDABLE'] mapping = [ ('use-build-blocker', 'useBuildBlocker', True), ('', 'blockingJobs', jobs), - ('blocking-level', 'blockLevel', 'GLOBAL', ('GLOBAL', 'NODE')), - ('queue-scanning', 'scanQueueFor', 'DISABLED', - ('DISABLED', 'ALL', 'BUILDABLE')), + ('blocking-level', 'blockLevel', 'GLOBAL', block_level_types), + ('queue-scanning', 'scanQueueFor', 'DISABLED', queue_scan_types), ] helpers.convert_mapping_to_xml(blocker, data, mapping, fail_required=True) diff --git a/tests/properties/fixtures/build-blocker01.xml b/tests/properties/fixtures/build-blocker-full.xml similarity index 92% rename from tests/properties/fixtures/build-blocker01.xml rename to tests/properties/fixtures/build-blocker-full.xml index 05e32aa8f..7ae82b713 100644 --- a/tests/properties/fixtures/build-blocker01.xml +++ b/tests/properties/fixtures/build-blocker-full.xml @@ -4,8 +4,7 @@ true .*-deploy -^maintenance.* - +^maintenance.* GLOBAL BUILDABLE diff --git a/tests/properties/fixtures/build-blocker01.yaml b/tests/properties/fixtures/build-blocker-full.yaml similarity index 100% rename from tests/properties/fixtures/build-blocker01.yaml rename to tests/properties/fixtures/build-blocker-full.yaml diff --git a/tests/properties/fixtures/build-blocker-minimal.xml b/tests/properties/fixtures/build-blocker-minimal.xml new file mode 100644 index 000000000..e87a6638c --- /dev/null +++ b/tests/properties/fixtures/build-blocker-minimal.xml @@ -0,0 +1,11 @@ + + + + + true + .*-deploy + GLOBAL + DISABLED + + + diff --git a/tests/properties/fixtures/build-blocker-minimal.yaml b/tests/properties/fixtures/build-blocker-minimal.yaml new file mode 100644 index 000000000..c794723de --- /dev/null +++ b/tests/properties/fixtures/build-blocker-minimal.yaml @@ -0,0 +1,4 @@ +properties: + - build-blocker: + blocking-jobs: + - ".*-deploy"