Jenkins带参数每月第三个周五23点执行的正确Cron表达式咨询
Hey there! Let's fix that cron syntax error you're hitting in your Jenkinsfile.
The issue with your original expression 0 23 ? * FRI#3 is that Jenkins (and specifically the parameterizedCron plugin) doesn't support combining weekday abbreviations like FRI with the #N syntax for specifying the nth occurrence of a weekday. Instead, you need to use the numerical value for Friday paired with the #3 suffix.
Here's the corrected parameterizedCron block you should use:
parameterizedCron(''' 0 23 * * 5#3 %INPUT-CHOICE=XXX; HOSTS=YYY ''')
Let me break this down for clarity:
0= Run at the 0th minute (top of the hour)23= Run at 11 PM (23:00 in 24-hour time)*= Run on any day of the month (no need to restrict this since we're using the week-based rule)*= Run in any month5#3= Run on the 3rd Friday of the month (5 represents Friday in Jenkins' cron syntax, where 0=Sunday, 1=Monday, ..., 5=Friday, 6=Saturday)
The parameter section %INPUT-CHOICE=XXX; HOSTS=YYY stays exactly as you had it—this will pass those pre-defined parameters to your job when it triggers on the scheduled time.
If you ever need to double-check cron syntax for Jenkins, you can use the built-in helper in your job's configuration: just find the "Build periodically" field and click the question mark icon next to it for detailed valid syntax rules.
备注:内容来源于stack exchange,提问作者SriDev

