summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-08-02 09:36:53 +0000
committerGerrit Code Review <review@openstack.org>2018-08-02 09:36:53 +0000
commitb23394b47bac956765e682acc93d2c4debb8b0e7 (patch)
treeda452894b63c7fae70e9bfd0380bc67537152635
parent9428f49fe017ff5751c9e43042fcc27fcf7390ba (diff)
parente9702144be0c43821c8da073249e36b9e7f71f31 (diff)
Merge "Add matching parameter to throttle concurrent jobs"
-rw-r--r--jenkins_jobs/modules/properties.py9
-rw-r--r--tests/properties/fixtures/throttle001.xml2
-rw-r--r--tests/properties/fixtures/throttle002.xml2
-rw-r--r--tests/properties/fixtures/throttle002.yaml4
4 files changed, 17 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py
index c1dbc36..59b6b1a 100644
--- a/jenkins_jobs/modules/properties.py
+++ b/jenkins_jobs/modules/properties.py
@@ -241,6 +241,10 @@ def throttle(registry, xml_parent, data):
241 :arg list categories: multiproject throttle categories 241 :arg list categories: multiproject throttle categories
242 :arg bool matrix-builds: throttle matrix master builds (default true) 242 :arg bool matrix-builds: throttle matrix master builds (default true)
243 :arg bool matrix-configs: throttle matrix config builds (default false) 243 :arg bool matrix-configs: throttle matrix config builds (default false)
244 :arg str parameters-limit: prevent jobs with matching parameters from
245 running concurrently (default false)
246 :arg list parameters-check-list: Comma-separated list of parameters
247 to use when comparing jobs (optional)
244 248
245 Example: 249 Example:
246 250
@@ -269,6 +273,7 @@ def throttle(registry, xml_parent, data):
269 mapping = [ 273 mapping = [
270 ('', 'throttleOption', option), 274 ('', 'throttleOption', option),
271 ('', 'configVersion', '1'), 275 ('', 'configVersion', '1'),
276 ('parameters-limit', 'limitOneJobWithMatchingParams', False),
272 ] 277 ]
273 helpers.convert_mapping_to_xml(throttle, data, mapping, fail_required=True) 278 helpers.convert_mapping_to_xml(throttle, data, mapping, fail_required=True)
274 279
@@ -280,6 +285,10 @@ def throttle(registry, xml_parent, data):
280 helpers.convert_mapping_to_xml( 285 helpers.convert_mapping_to_xml(
281 matrixopt, data, mapping, fail_required=True) 286 matrixopt, data, mapping, fail_required=True)
282 287
288 params_to_use = data.get('parameters-check-list', [])
289 XML.SubElement(throttle, 'paramsToUseForLimit').text = ",".join(
290 params_to_use)
291
283 292
284def branch_api(registry, xml_parent, data): 293def branch_api(registry, xml_parent, data):
285 """yaml: branch-api 294 """yaml: branch-api
diff --git a/tests/properties/fixtures/throttle001.xml b/tests/properties/fixtures/throttle001.xml
index 829eff1..c0ca3b1 100644
--- a/tests/properties/fixtures/throttle001.xml
+++ b/tests/properties/fixtures/throttle001.xml
@@ -11,10 +11,12 @@
11 </categories> 11 </categories>
12 <throttleOption>category</throttleOption> 12 <throttleOption>category</throttleOption>
13 <configVersion>1</configVersion> 13 <configVersion>1</configVersion>
14 <limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams>
14 <matrixOptions> 15 <matrixOptions>
15 <throttleMatrixBuilds>false</throttleMatrixBuilds> 16 <throttleMatrixBuilds>false</throttleMatrixBuilds>
16 <throttleMatrixConfigurations>true</throttleMatrixConfigurations> 17 <throttleMatrixConfigurations>true</throttleMatrixConfigurations>
17 </matrixOptions> 18 </matrixOptions>
19 <paramsToUseForLimit/>
18 </hudson.plugins.throttleconcurrents.ThrottleJobProperty> 20 </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
19 </properties> 21 </properties>
20</project> 22</project>
diff --git a/tests/properties/fixtures/throttle002.xml b/tests/properties/fixtures/throttle002.xml
index 48373a7..d63b36a 100644
--- a/tests/properties/fixtures/throttle002.xml
+++ b/tests/properties/fixtures/throttle002.xml
@@ -11,10 +11,12 @@
11 </categories> 11 </categories>
12 <throttleOption>project</throttleOption> 12 <throttleOption>project</throttleOption>
13 <configVersion>1</configVersion> 13 <configVersion>1</configVersion>
14 <limitOneJobWithMatchingParams>true</limitOneJobWithMatchingParams>
14 <matrixOptions> 15 <matrixOptions>
15 <throttleMatrixBuilds>true</throttleMatrixBuilds> 16 <throttleMatrixBuilds>true</throttleMatrixBuilds>
16 <throttleMatrixConfigurations>false</throttleMatrixConfigurations> 17 <throttleMatrixConfigurations>false</throttleMatrixConfigurations>
17 </matrixOptions> 18 </matrixOptions>
19 <paramsToUseForLimit>param1,param2</paramsToUseForLimit>
18 </hudson.plugins.throttleconcurrents.ThrottleJobProperty> 20 </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
19 </properties> 21 </properties>
20</project> 22</project>
diff --git a/tests/properties/fixtures/throttle002.yaml b/tests/properties/fixtures/throttle002.yaml
index cd9b36d..bb1822a 100644
--- a/tests/properties/fixtures/throttle002.yaml
+++ b/tests/properties/fixtures/throttle002.yaml
@@ -4,3 +4,7 @@ properties:
4 - cat1 4 - cat1
5 - cat2 5 - cat2
6 option: project 6 option: project
7 parameters-limit: true
8 parameters-check-list:
9 - 'param1'
10 - 'param2'