본문 바로가기
Programming/etc

Jenkins(젠킨스) 빌드 유발 주기설정

by ciwhiz 2021. 8. 23.

(예시)들 몇 가지. 

H 6 * * *  -> 매일 새벽 6시 OO분에 실행
H 7 * * 2,5  -> 매주 화, 금요일 오전 7시 OO분에 실행
H 23 3 * * ->  매달 3일 23시 OO분에 실행

 

 

젠킨스 도움말 번역.

 

이 필드는 cron 구문을 따릅니다(사소한 차이가 있음). 특히 각 줄은 TAB 또는 공백으로 구분된 5개의 필드로 구성됩니다. MINUTE HOUR DOM MONTH DOW

MINUTE 시간 내 분(0–59)
HOUR 하루 중 시간(0–23)
DOM 날짜(1–31)
MONTH 월(1–12)
DOW 0과 7이 일요일인 요일(0–7)입니다.
한 필드에 여러 값을 지정하려면 다음 연산자를 사용할 수 있습니다. 우선순위에 따라,

* 모든 유효한 값을 지정합니다
M-N은 값 범위를 지정합니다.
지정된 범위 또는 전체 유효 범위를 통해 X 간격으로 M-N/X 또는 */X 단계
A,B,...,Z는 여러 값을 열거합니다.
주기적으로 예약된 작업이 시스템에 균일한 부하를 생성할 수 있도록 하려면 가능한 모든 곳에서 기호 H("해시")를 사용해야 합니다. 
예를 들어, 12개의 일일 작업에 0 0 * * *를 사용하면 자정에 큰 폭으로 증가합니다. 
대조적으로, H H * * *를 사용하면 여전히 각 작업을 하루에 한 번 실행하지만 동시에 모든 작업을 실행하지는 않으므로 제한된 리소스를 사용하는 것이 좋습니다.

H 기호는 범위와 함께 사용할 수 있습니다. 
예를 들어, H H(0-7) * * *는 오전 12:00(자정)에서 오전 7:59 사이의 시간을 의미합니다. 
범위가 있거나 없는 H와 함께 단계 간격을 사용할 수도 있습니다.

H 기호는 범위에 대한 임의의 값으로 생각할 수 있지만 실제로는 임의의 함수가 아닌 작업 이름의 해시이므로 주어진 프로젝트에서 값이 안정적으로 유지됩니다.

월 필드의 경우 */3 또는 H/3과 같은 짧은 주기는 다양한 월 길이로 인해 대부분의 월말에 일관되게 작동하지 않습니다. 
예를 들어 */3은 긴 달의 1일, 4일, … 31일에 실행되고 다음 달의 다음 날에 다시 실행됩니다. 
해시는 항상 1-28 범위에서 선택되므로 H/3은 월말에 실행 사이에 3일에서 6일 사이의 간격을 생성합니다. 
(긴 주기도 길이가 일정하지 않지만 효과는 상대적으로 덜 눈에 띌 수 있습니다.)

빈 줄과 #으로 시작하는 줄은 주석으로 무시됩니다.

또한 @yearly, @annually, @monthly, @weekly, @daily, @midnight, @hourly는 편리한 별칭으로 지원됩니다. 
이들은 자동 균형 조정을 위해 해시 시스템을 사용합니다. 
예를 들어 @hourly는 H * * * *와 동일하며 시간 중 언제든지를 의미할 수 있습니다. 
@midnight는 실제로 오전 12시에서 오전 2시 59분 사이의 시간을 의미합니다.

예:
# 매 15분마다 (아마도 :07, :22, :37, :52): H/15 * * * * 
# 매시 전반부에 매 10분마다 (세 번, 아마도 :04, :14, :24): H(0-29)/10 * * * * 
# 평일 오전 9시 45분에 시작하여 오후 3시 45분에 끝나는 시간 45분에 2시간마다 1회: 45 9-16/2 * * 1-5 
# 평일 오전 8시~오후 4시(아마도 오전 9시 38분, 오전 11시 38분, 오후 1시 38분, 오후 3시 38분) 사이에 2시간마다 한 번씩: H H(8-15)/ 2 * * 1-5 
# 12월을 제외한 매월 1일과 15일에 1일 1회 : H H 1,15 1-11 * 

 

This field follows the syntax of cron (with minor differences). Specifically, each line consists of 5 fields separated by TAB or whitespace:MINUTE HOUR DOM MONTH DOW

MINUTE Minutes within the hour (0–59)
HOUR The hour of the day (0–23)
DOM The day of the month (1–31)
MONTH The month (1–12)
DOW The day of the week (0–7) where 0 and 7 are Sunday.
To specify multiple values for one field, the following operators are available. In the order of precedence,

* specifies all valid values
M-N specifies a range of values
M-N/X or */X steps by intervals of X through the specified range or whole valid range
A,B,...,Z enumerates multiple values
To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”) should be used wherever possible. For example, using 0 0 * * * for a dozen daily jobs will cause a large spike at midnight. In contrast, using H H * * * would still execute each job once a day, but not all at the same time, better using limited resources.

The H symbol can be used with a range. For example, H H(0-7) * * * means some time between 12:00 AM (midnight) to 7:59 AM. You can also use step intervals with H, with or without ranges.

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

Beware that for the day of month field, short cycles such as */3 or H/3 will not work consistently near the end of most months, due to variable month lengths. For example, */3 will run on the 1st, 4th, …31st days of a long month, then again the next day of the next month. Hashes are always chosen in the 1-28 range, so H/3 will produce a gap between runs of between 3 and 6 days at the end of a month. (Longer cycles will also have inconsistent lengths but the effect may be relatively less noticeable.)

Empty lines and lines that start with # will be ignored as comments.

In addition, @yearly, @annually, @monthly, @weekly, @daily, @midnight, and @hourly are supported as convenient aliases. These use the hash system for automatic balancing. For example, @hourly is the same as H * * * * and could mean at any time during the hour. @midnight actually means some time between 12:00 AM and 2:59 AM.

Examples:

# Every fifteen minutes (perhaps at :07, :22, :37, :52): H/15 * * * * 

# Every ten minutes in the first half of every hour (three times, perhaps at :04, :14, :24): H(0-29)/10 * * * * 

# Once every two hours at 45 minutes past the hour starting at 9:45 AM and finishing at 3:45 PM every weekday: 45 9-16/2 * * 1-5 

# Once in every two hour slot between 8 AM and 4 PM every weekday (perhaps at 9:38 AM, 11:38 AM, 1:38 PM, 3:38 PM): H H(8-15)/2 * * 1-5 

# Once a day on the 1st and 15th of every month except December: H H 1,15 1-11 *