summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakulakhan <kuhlmann.andrew@gmail.com>2016-11-29 14:44:31 -0800
committertanhengyeow <E0032242@u.nus.edu>2018-08-01 23:35:25 +0800
commite9702144be0c43821c8da073249e36b9e7f71f31 (patch)
tree9e70a091eae5c2cd7ea4c8e8f48fc5183ee46ff3
parentc33dbaaaae0cc760498924dc25c7c99396c5702b (diff)
Add matching parameter to throttle concurrent jobs
Change-Id: I6d211508d774df2312942d56a840bf311bb455d4 Co-Authored-By: Tan Heng Yeow <E0032242@u.nus.edu> Signed-off-by: Tan Heng Yeow <E0032242@u.nus.edu>
Notes
Notes (review): Code-Review+2: Thanh Ha <zxiiro@gmail.com> Code-Review+2: Kien Ha <kienha9922@gmail.com> Workflow+1: Kien Ha <kienha9922@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 02 Aug 2018 09:36:53 +0000 Reviewed-on: https://review.openstack.org/404454 Project: openstack-infra/jenkins-job-builder Branch: refs/heads/master
-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'