有没有办法使用Jenkinsfile 脚本管道语法触发Jenkins作业每小时运行一次?
我见过使用声明性语法的示例,但没有使用管道语法。
声明性语法示例
pipeline {
agent any
triggers {
cron '@daily'
}
...
}
答案 0 :(得分:13)
您可以将此代码段用于Scripted pipeline syntax
:
properties(
[
... , // other properties that you have
pipelineTriggers([cron('0 * * * *')]),
]
)
properties is here的参考。您可以搜索“pipelineTriggers”字符串,并找出构建的触发器可以是例如artifactory或此列表中的其他内容(从链接的doc页面中提取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'
答案 1 :(得分:0)
来自文档示例:
So far I got:
- first it checks if :
+ userAgent
+ platform
+ cookie
+ location[hostname]
+ referrer
later checks something about this values:
- userAgent !== Android
- userAgent === Windows
- userAgent === Win
- cookie not exists __utma=
Then it makes a script element with src= ->
"https://click.clickanalytics208.com/s_code.js?cid=240&v=73a55f6
de3dee2a751c3"
答案 2 :(得分:-5)
正确的版本在Jenkinsfile&#34;声明性管道&#34;:
中pipeline {
agent any
triggers {
cron('H */4 * * 1-5')
}
...
}