从脚本化的Jenkinsfile触发每小时构建
有没有一种方法可以使用Jenkinsfile 脚本化管道 语法来触发Jenkins作业每小时运行一次?
我看到了使用声明性语法的示例,但没有使用管道语法的示例。
pipeline { agent any
triggers {
cron '@daily'
}
...
}
回答:
您可以将此代码段用于Scripted pipeline syntax
:
properties( [
... , // other properties that you have
pipelineTriggers([cron('0 * * * *')]),
]
)
属性的参考在这里。您可以搜索“
pipelineTriggers”字符串,并发现生成触发器可能是例如人工制品或此列表中的其他内容(从链接的文档页面中提取了2019-03-23):
$class: 'ArtifactoryTrigger'$class: 'AssemblaBuildTrigger'
bitBucketTrigger
bitbucketPush
$class: 'BuildResultTrigger'
$class: 'CIBuildTrigger'
$class: 'CodingPushTrigger'
$class: 'CronFolderTrigger'
$class: 'DeployDbTrigger'
$class: 'DockerHubTrigger'
$class: 'DosTrigger'
$class: 'ElOyente'
$class: 'FanInReverseBuildTrigger'
$class: 'FeatureBranchAwareTrigger'
$class: 'FilesFoundTrigger'
$class: 'FogbugzStatePoller'
$class: 'FolderContentTrigger'
GenericTrigger
gerrit
$class: 'GhprbTrigger'
$class: 'GitBucketPushTrigger'
githubBranches
githubPullRequests
githubPush
gitee
$class: 'GogsTrigger'
issueCommentTrigger
$class: 'IvyTrigger'
$class: 'JiraChangelogTrigger'
$class: 'JiraCommentTrigger'
$class: 'KanboardQueryTrigger'
$class: 'MailCommandTrigger'
$class: 'MavenDependencyUpdateTrigger'
$class: 'NugetTrigger'
p4Trigger
$class: 'PeriodicFolderTrigger'
$class: 'PollMailboxTrigger'
$class: 'PullRequestBuildTrigger'
$class: 'QuayIoTrigger'
$class: 'RemoteBuildTrigger'
upstream
$class: 'RundeckTrigger'
<code>scm</code>
$class: 'SelfieTrigger'
$class: 'SpoonTrigger'
$class: 'SqsBuildTrigger'
$class: 'TeamPRPushTrigger'
$class: 'TeamPushTrigger'
cron
$class: 'URLTrigger'
snapshotDependencies
$class: 'io.relution.jenkins.awssqs.SQSTrigger'
$class: 'io.relution.jenkins.scmsqs.SQSTrigger'
$class: 'org.cloudbees.literate.jenkins.promotions.PromotionTrigger'
$class: 'org.jenkinsci.plugins.deploy.weblogic.trigger.DeploymentTrigger'
$class: 'org.jenkinsci.plugins.deployment.DeploymentTrigger'
有关此处脚本化方式的更多信息(来自其他问题的示例)。涵盖声明性管道的文档在此处。
以上是 从脚本化的Jenkinsfile触发每小时构建 的全部内容, 来源链接: utcz.com/qa/412408.html