从脚本化的 Jenkinsfile 触发每小时构建
Trigger hourly build from scripted Jenkinsfile
有没有办法使用 Jenkinsfile 脚本管道 语法每小时触发 Jenkins 作业 运行?
我看过使用声明性语法的示例,但 none 使用管道语法。
声明性语法示例
pipeline {
agent any
triggers {
cron '@daily'
}
...
}
您可以将此代码段用于 Scripted pipeline syntax
:
properties(
[
... , // other properties that you have
pipelineTriggers([cron('0 * * * *')]),
]
)
参考 properties is here。您可以搜索 "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'
有关脚本化方式的更多信息 (来自另一个问题的样本)。
涵盖声明性管道的文档是 here.
正确的版本在 Jenkinsfile 中 "Declarative Pipeline":
pipeline {
agent any
triggers {
cron('H */4 * * 1-5')
}
...
}
有没有办法使用 Jenkinsfile 脚本管道 语法每小时触发 Jenkins 作业 运行?
我看过使用声明性语法的示例,但 none 使用管道语法。
声明性语法示例
pipeline {
agent any
triggers {
cron '@daily'
}
...
}
您可以将此代码段用于 Scripted pipeline syntax
:
properties(
[
... , // other properties that you have
pipelineTriggers([cron('0 * * * *')]),
]
)
参考 properties is here。您可以搜索 "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 中 "Declarative Pipeline":
pipeline {
agent any
triggers {
cron('H */4 * * 1-5')
}
...
}