diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index c1dbc36dd..59b6b1a96 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -241,6 +241,10 @@ def throttle(registry, xml_parent, data): :arg list categories: multiproject throttle categories :arg bool matrix-builds: throttle matrix master builds (default true) :arg bool matrix-configs: throttle matrix config builds (default false) + :arg str parameters-limit: prevent jobs with matching parameters from + running concurrently (default false) + :arg list parameters-check-list: Comma-separated list of parameters + to use when comparing jobs (optional) Example: @@ -269,6 +273,7 @@ def throttle(registry, xml_parent, data): mapping = [ ('', 'throttleOption', option), ('', 'configVersion', '1'), + ('parameters-limit', 'limitOneJobWithMatchingParams', False), ] helpers.convert_mapping_to_xml(throttle, data, mapping, fail_required=True) @@ -280,6 +285,10 @@ def throttle(registry, xml_parent, data): helpers.convert_mapping_to_xml( matrixopt, data, mapping, fail_required=True) + params_to_use = data.get('parameters-check-list', []) + XML.SubElement(throttle, 'paramsToUseForLimit').text = ",".join( + params_to_use) + def branch_api(registry, xml_parent, data): """yaml: branch-api diff --git a/tests/properties/fixtures/throttle001.xml b/tests/properties/fixtures/throttle001.xml index 829eff1c6..c0ca3b1a4 100644 --- a/tests/properties/fixtures/throttle001.xml +++ b/tests/properties/fixtures/throttle001.xml @@ -11,10 +11,12 @@ category 1 + false false true + diff --git a/tests/properties/fixtures/throttle002.xml b/tests/properties/fixtures/throttle002.xml index 48373a76b..d63b36a26 100644 --- a/tests/properties/fixtures/throttle002.xml +++ b/tests/properties/fixtures/throttle002.xml @@ -11,10 +11,12 @@ project 1 + true true false + param1,param2 diff --git a/tests/properties/fixtures/throttle002.yaml b/tests/properties/fixtures/throttle002.yaml index cd9b36d0a..bb1822a08 100644 --- a/tests/properties/fixtures/throttle002.yaml +++ b/tests/properties/fixtures/throttle002.yaml @@ -4,3 +4,7 @@ properties: - cat1 - cat2 option: project + parameters-limit: true + parameters-check-list: + - 'param1' + - 'param2'