首页 文章

从脚本化的Jenkinsfile触发每小时构建

提问于
浏览
7

有没有办法使用Jenkinsfile脚本管道语法触发Jenkins作业每小时运行一次?

我见过使用声明性语法的示例,但没有使用管道语法 .

Declarative Syntax Example

pipeline {
    agent any

    triggers {
        cron '@daily'
    }

   ...
}

2 回答

  • 8

    您可以将此代码段用于 Scripted pipeline syntax

    properties(
        [
            ...  , // other properties that you have
            pipelineTriggers([cron('0 * * * *')]),
        ]
    )
    

    更多信息here .
    涵盖声明性管道的文档是here .

  • -4

    正确的版本是在Jenkinsfile“声明性管道”中:

    pipeline {
        agent any
        triggers {
            cron('H */4 * * 1-5')
        }
    ...
    }
    

相关问题