Setting timed tasks for Jenkins entry

1. Create a task first. If you don’t know how to do it, you can refer to my previous article - New Task for Getting Started with Jenkins: https://blog.csdn.net/weixin_48520816/article/details/125209616

2. After entering the task, click Configure Configure
insert image description here
3. Set a scheduled build

insert image description here

4. Rules for timing time setting

I understand the time rules , followed by an official version, some students may be able to realize more through the official version
insert image description here

The following is the official explanation

Specifically, each line contains 5 fields, which are minutes, hours, days, months, and days of the week, separated by tabs or spaces.
minute minute of the hour (0–59)
hour hour of the day (0–23)
DOM day of the month (1–31)
month month (1–12)
day of the week (0–7), where 0 and 7 are Sunday.
To specify multiple values ​​for a field, the following operators can be used. In order of priority,
*specify all valid values
​​MN specifies the range of values ​​MN/X or */X steps A,B,…,Z
at intervals of X within the specified range or the entire valid range to enumerate multiple values

To allow regularly scheduled tasks to produce an even load on the system, H should use symbols (for "hash") whenever possible. For example, using 0 0 * * * for a dozen daily jobs would result in a large spike at midnight. In contrast, usingH H * * * will still execute each job once a day, but not all at once, better using limited resources.

The H notation can be used with ranges. For example, HH(0-7) * * * represents a time between 12:00 AM (midnight) and 7:59 AM. You can also use step interval with H, with or without range.

The H symbol can be thought of as a random value within a range, but it's actually a hash of the job name, not a random function, so the value remains stable for any given project.

Note that for month fields, short periods (e.g. */3 or H/3 won't consistently end most months) work due to varying month lengths. For example, */3 will run on days 1, 4, ... 31 of a long month, then again on the second day of the following month. Hash values ​​are always chosen in the range 1-28, so H/3 produces a gap of 3 to 6 days between runs at the end of the month. (Longer periods also have inconsistent lengths, but the effect may be less pronounced.)

Empty lines and lines starting with # are ignored as comments.

Additionally, @yearly, @annually, @monthly, @weekly, @daily, @midnight, and @hourly are supported as convenient aliases. These are automatically balanced using a hashing system. For example, @hourly is the same as H * * * * and may mean any time within an hour. @midnight actually means sometime between 12:00 AM and 2:59 AM.

example:

# 每十五分钟(可能在 :07, :22, :37, :52):
H/15 * * * *
# 每小时前半段每十分钟一次(3 次,可能在 :04, :14, :24):
H(0-29)/10 * * * *
# 每两小时一次,每两个小时一次,从上午 945 分开始,到每个工作日下午 345 分结束,每小时 45 分钟:
45 9-16/2 * * 1-5
# 每个工作日上午 8 点到下午 4 点之间每两小时一次(可能在上午 9:38、上午 11:38、下午 1:38、下午 3:38):
HH(8-15)/2 * * 1-5
# 除 12 月外,每月 1 日和 15 日每天一次:
HH 1,15 1-11 *

Other jenkins articles:

1. New task for getting started with Jenkins: https://blog.csdn.net/weixin_48520816/article/details/125209616
2. curl for Jenkins automated continuous integration: https://blog.csdn.net/weixin_48520816/article/details/ 125209290

Guess you like

Origin blog.csdn.net/weixin_48520816/article/details/125221752