Browse Source

Merge "Add matching parameter to throttle concurrent jobs"

Zuul 8 months ago
parent
commit
b23394b47b

+ 9
- 0
jenkins_jobs/modules/properties.py View File

@@ -241,6 +241,10 @@ def throttle(registry, xml_parent, data):
241 241
     :arg list categories: multiproject throttle categories
242 242
     :arg bool matrix-builds: throttle matrix master builds (default true)
243 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 249
     Example:
246 250
 
@@ -269,6 +273,7 @@ def throttle(registry, xml_parent, data):
269 273
     mapping = [
270 274
         ('', 'throttleOption', option),
271 275
         ('', 'configVersion', '1'),
276
+        ('parameters-limit', 'limitOneJobWithMatchingParams', False),
272 277
     ]
273 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 285
     helpers.convert_mapping_to_xml(
281 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
 
284 293
 def branch_api(registry, xml_parent, data):
285 294
     """yaml: branch-api

+ 2
- 0
tests/properties/fixtures/throttle001.xml View File

@@ -11,10 +11,12 @@
11 11
       </categories>
12 12
       <throttleOption>category</throttleOption>
13 13
       <configVersion>1</configVersion>
14
+      <limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams>
14 15
       <matrixOptions>
15 16
         <throttleMatrixBuilds>false</throttleMatrixBuilds>
16 17
         <throttleMatrixConfigurations>true</throttleMatrixConfigurations>
17 18
       </matrixOptions>
19
+      <paramsToUseForLimit/>
18 20
     </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
19 21
   </properties>
20 22
 </project>

+ 2
- 0
tests/properties/fixtures/throttle002.xml View File

@@ -11,10 +11,12 @@
11 11
       </categories>
12 12
       <throttleOption>project</throttleOption>
13 13
       <configVersion>1</configVersion>
14
+      <limitOneJobWithMatchingParams>true</limitOneJobWithMatchingParams>
14 15
       <matrixOptions>
15 16
         <throttleMatrixBuilds>true</throttleMatrixBuilds>
16 17
         <throttleMatrixConfigurations>false</throttleMatrixConfigurations>
17 18
       </matrixOptions>
19
+      <paramsToUseForLimit>param1,param2</paramsToUseForLimit>
18 20
     </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
19 21
   </properties>
20 22
 </project>

+ 4
- 0
tests/properties/fixtures/throttle002.yaml View File

@@ -4,3 +4,7 @@ properties:
4 4
         - cat1
5 5
         - cat2
6 6
       option: project
7
+      parameters-limit: true
8
+      parameters-check-list:
9
+        - 'param1'
10
+        - 'param2'

Loading…
Cancel
Save