fix branch-api valid time periods

removes first letter capitalization from the valid time periods, e.g.:
    - Second -> second;
    - Minute -> minute;
    - Hour -> hour;
    - and so on...
- only lowercase time periods are recognized by Jenkins Branch API Plugin:
    - that can be observed on the plugin implementations themselves:
        - https://github.com/jenkinsci/branch-api-plugin/search?q=Minute
        - on the Message.properties file it can be verified that the
          value of the "Minute" property is actually "minute", and that
          can also be validated pratically, setting the durationName
          XML to "Minute" is not effective, Jenkins effectively
          interprets it as default "Hour" since "Minute" is not valid.

Change-Id: I25f0a3945b9d708fa2de5c5fdb7f39a9432b5cc3
This commit is contained in:
Ruan Bahia 2022-12-08 14:35:13 -03:00
parent fee4e65cec
commit da50ce7320
6 changed files with 9 additions and 9 deletions

View File

@ -381,9 +381,9 @@ def branch_api(registry, xml_parent, data):
:arg int number-of-builds: The maximum number of builds allowed within
the specified time period. (default 1)
:arg str time-period: The time period within which the maximum number
of builds will be enforced. (default 'Hour')
of builds will be enforced. (default 'hour')
:valid values: **Second** **Minute** **Hour**, **Day**, **Week**, **Month**, **Year**
:valid values: **second** **minute** **hour**, **day**, **week**, **month**, **year**
:arg bool skip-rate-limit: Permit user triggered builds to
skip the rate limit (default false)
@ -404,10 +404,10 @@ def branch_api(registry, xml_parent, data):
)
branch.set("plugin", "branch-api")
valid_time_periods = ["Second", "Minute", "Hour", "Day", "Week", "Month", "Year"]
valid_time_periods = ["second", "minute", "hour", "day", "week", "month", "year"]
mapping = [
("time-period", "durationName", "Hour", valid_time_periods),
("time-period", "durationName", "hour", valid_time_periods),
("number-of-builds", "count", 1),
("skip-rate-limit", "userBoost", False),
]

View File

@ -2,7 +2,7 @@
<project>
<properties>
<jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api">
<durationName>Day</durationName>
<durationName>day</durationName>
<count>5</count>
<userBoost>true</userBoost>
</jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl>

View File

@ -1,5 +1,5 @@
properties:
- branch-api:
time-period: Day
time-period: day
number-of-builds: 5
skip-rate-limit: true

View File

@ -2,7 +2,7 @@
<project>
<properties>
<jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api">
<durationName>Hour</durationName>
<durationName>hour</durationName>
<count>1</count>
<userBoost>false</userBoost>
</jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl>

View File

@ -2,7 +2,7 @@
<project>
<properties>
<jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api">
<durationName>Minute</durationName>
<durationName>minute</durationName>
<count>3</count>
<userBoost>false</userBoost>
</jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl>

View File

@ -1,4 +1,4 @@
properties:
- branch-api:
time-period: Minute
time-period: minute
number-of-builds: 3