首页 > 解决方案 > 如何每天自动执行一次詹金斯作业

问题描述

在詹金斯的工作中,我们有一个选项“定期构建”。那么在 IST 时间晚上 10:30 自动运行作业的参数是什么。

我尝试将 30 22 * * TZ=IST 作为参数,但它对我不起作用。

标签: jenkinsjenkins-pipeline

解决方案


单击计划框旁边的问号以获得对语法的全面解释。
它在那里说:

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.

因此,在您的情况下,您需要输入:

30 22 * * * 

关于时区,文档说:

Time zone specification

Periodic tasks are normally executed at the scheduled time in the time zone of 
the Jenkins master JVM (currently Europe/Berlin). This behavior can optionally 
be changed by specifying an alternative time zone in the first line of the field. 
Timezone specification starts with TZ=, followed by the ID of a time zone. 

因此,您的完整 cron 条目是:

TZ=Asia/Istanbul
30 22 * * * 

推荐阅读