2017-05-22 25 views
0

有没有办法触发詹金斯作业每小时运行使用Jenkinsfile 脚本管道语法?触发每小时从脚本Jenkinsfile生成

我看过使用声明语法的例子,但没有使用管道语法。

声明语法示例

pipeline { 
    agent any 

    triggers { 
     cron '@daily' 
    } 

    ... 
} 
+2

[詹金斯构建流水线计划触发(可能的重复https://stackoverflow.com/questions/32028761/jenkins-build-pipeline -scheduled-trigger) – StephenKing

回答

2

您可以使用此代码段为Scripted pipeline syntax

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

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

+1

它在jenkins 2.79下的脚本管道中不起作用(java.lang.UnsupportedOperationException:未定义的符号'pipelineTriggers') – Eric

1

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

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